1. 程式人生 > >學習HTML5(二) - jQuery 模態框學習

學習HTML5(二) - jQuery 模態框學習

模型根據不同的按鈕而變化

連結: https://v3.bootcss.com/javascript/#modals

個人總結

Have a bunch of buttons that all trigger the same modal, just with slightly different contents? Use event.relatedTarget and HTML data-*

 attributes (possibly via jQuery) to vary the contents of the modal depending on which button was clicked. See the Modal Events docs for details on relatedTarget,

翻譯:有許多按鈕都觸發同一個視窗,只是內容不一樣?

使用event.relatedTarget屬性和HTML data-* 屬性使得視窗內容與具體按鈕關聯起來。

$('#exampleModal').on('show.bs.modal', function (event) {
  var button = $(event.relatedTarget) // 觸發視窗的按鈕
  var recipient = button.data('whatever') // 從data-*屬性中提取資訊
  // 如有必要, 你可以在這裡初始化一個AJAX請求然後在回撥中更新資訊.
  // 更新視窗的內容. 我們在這使用jQuery, 但你可以用a data binding library或者other methods.
  var modal = $(this)
  modal.find('.modal-title').text('New message to ' + recipient)
  modal.find('.modal-body input').val(recipient)
})

其它具體問題參見原連結。

 

jQuery 選擇器總結:jQuery選擇器(總結的非常好)

 

jQuery操作select控制元件:jquery操作select(取值,設定選中) - Jaye118 - 部落格園

 

好用的jQuery多選框外掛

連結jQuery multiselect