In addition to controlling modal popups through Data-toggle and Data-target, the bootstrap framework provides additional custom data-properties for modal pop-up boxes to control modal popups. For example: whether there is a gray background modal-backdrop, you can press the ESC key to close the modal pop-up window. Instructions for customizing properties for modal popup are as follows:
<! DOCTYPE html>
JavaScript Trigger method
In addition to using a custom attribute to trigger a modal popup, a modal popup can also be triggered by a JavaScript method. By giving an element an event to trigger. For example, give a button a click event , and then trigger a modal popup window. As a simple example below:
<!--trigger modal popup element--><button class= "btnBtn-primary "type=" button "> click I </button><!--modal popup content--><div class=" modal "id= "Mymodal"> <div class= "Modal-dialog" > <div class= "modal-content" > <div class= "Modal-header" & Gt <button type= "button" class= "Close" data-dismiss= "modal" ><span aria-hidden= "true" >×</span ><span class= "sr-only" >Close</span></button> JavaScript-triggered Popup code:
$ (function () { $ (". BTN"). Click (function () { $ ("#mymodal"). modal (); });
The results are as follows:
Bootstarp Learning (24) modal popup--use of modal pop-up windows