Introduction to the Bootstrap model pop-up box using _javascript tips

Source: Internet
Author: User

Before, we explained the use of Bootstrap tab, today we come to understand the use of the Model pop-up window in bootstrap.

Effect:

Code:

<input id= "btntext" type= button "value=" Add text Component "data-toggle=" modal "data-target=" #myModal "href=". /sysmanage/zujianmanage.aspx "/>
<!--Modal-->
<div class=" Modal Hide Fade "id=" Mymodal "TabIndex = "-1" role= "dialog" >
<div class= "Modal-header" ><button class= "Close" type= "button" data-dismiss= " Modal ">x</button>

It's easy, it's OK.

Note: The Data-target attribute, pointing to the ID of model, so click on the button, model will bounce out.

Of course, you can also use JS to control.

The following code:

Showing: $ (' #myModal '). Modal (' show ');

Hidden: $ (' #myModal '). Modal (' hide ');

Switch: $ (' #myModal '). Modal (' Toogle ');

Event: $ (' #myModal '). On (' Hidden ', function () {//do something ...});

Note: I use the href attribute here, which is let model go to remote a URL. Of course, you can write the content you want directly in the model-body.

Seriously look at the model div structure, you will understand that Model-body is representative content, Model-header is the head, then if you want to add two buttons at the bottom, then you have to use the following code.

<div class= "Modal-footer" >
<a href= "#" class= "BTN" > Close </a>
<a href= "# class=" btn Btn-primary "> Save </a>
</div>

Note: If you want to set the width of the model, you must add the layout. is to put the model in the following code block, and set the width of model. Style= "width:500px". Yes, you can't just put it in the class with the span style.

<div class= "Container" ></div>

The above is a small series to introduce the Bootstrap model pop-up box use, I hope to help!

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.