Bootstrap modal use and click on the outside of the solution _javascript tips

Source: Internet
Author: User

The example of this article for everyone to share the use of bootstrap modal and click on the outside to disappear the solution, for your reference, the specific content as follows

1. 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> 

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 to let modal to remote a URL. Of course, you can write the content you want directly in the modal-body.

Seriously look at the modal div structure, you will understand that Modal-body is representative content, Modal-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> 

Note: If you want to set the width of the modal, you must add the layout. is to put the modal in the following code block and set the width of the modal. Style= "width:500px". By the right, you can't put the span style directly into class.

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

If you want the pop-up box to click outside and not disappear, add the following property to the component that triggers the modal box data-backdrop= "Static"

<div class= "Modal Hide Fade id=" Mymodal "tabindex="-1 "role=" dialog "<span style=" Font-family:arial 

, XXFarEastFont-Arial, Sans-serif, Tahoma, ' Microsoft Yahei '; font-size:14px; line-height:24px; " >

<span style= "color: #ff6666;" >data-backdrop= "Static" </span>

</span>> 
</div> 

For more information, please click on the topic "Bootstrap Modal use Tutorial" to learn, I hope you like.

The above is the entire content of this article, I hope to help you learn, but also hope that we support the cloud habitat community.

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.