Bootstrap every day must learn the warning box plug-in _javascript tips

Source: Internet
Author: User

Warning Boxes (alert) messages are mostly used to want the end user to display information such as a warning or acknowledgment message. Using the Warning box (alert) plug-in, you can add a dismiss feature to all warning box messages.

If you want to refer to the functionality of the plug-in separately, you need to refer to alert.js. Alternatively, as mentioned in the Bootstrap Plug-in Overview chapter, you can refer to the Bootstrap.js or compressed version of Bootstrap.min.js.

One, usage
You can enable the cancellation (dismissal) feature of the warning box in the following two ways:
1, through the Data property: Add the ability to cancel through the Data-dismiss= API, simply add "alert" to the Close button and automatically add a shutdown function to the warning box.

<a class= "Close" data-dismiss= "alert" href= "#" aria-hidden= "true" >
 x
</a>

2, through javascript: Add the ability to cancel through javascript:
$ (". Alert"). Alert ()

Second, simple examples

The warning box is the click-Hour information box.
1. Basic examples

<div class= "alert alert-warning" >     
 <button class= "Close" type= "button" data-dismiss= "alert" >   
 <span>x</span>      
 </button>      
 <p>       
 Warning: Your browser does not support!      
 </p>       

2, add fade effect

<div class= "alert alert-warning fade In" >
If you use JavaScript, you can replace data-dismiss= "alert."

JavaScript method

$ ('. Close '). In (' Click ', Function () {
 $ (' #alert '). Alert (' close ');
})

There are two types of events in the Alert plug-in:

event, other identical

$ (' #alert '). On (' Close.bs.alert ', function () {
 alert (') called when the Close method is triggered! ');
}); 

This series of tutorials is organized into: Bootstrap basic tutorials, welcome to click to learn.

If you want to further study, you can click here to learn, and then attach 3 wonderful topics:

Bootstrap Learning Course

Bootstrap Practical Course

Bootstrap Plugin Usage Tutorial

The above is the entire content of this article, I hope to learn bootstrap warning box plug-ins 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.