Bootstarp Learning (24) modal popup--use of modal pop-up windows

Source: Internet
Author: User
Tags button type

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" >&times;</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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.