Bootstrap Alter Plugin - Bootstrap

What is alter plugin in Bootstrap?

Alert messages are typically used to show statistics such as warning or confirmation messages to the end users. Using alert message plugin you can add discharge functionality to all alert messages.

If you want to include this plugin functionality individually, then you will need the alert.js. Otherwise, as stated in the section Bootstrap Plugins Summary, you can include the bootstrap.js or the minified bootstrap.min.js.

Usage

You can enable discharge of an alert in the subsequent two ways −

  • Through data attributes − to dismiss through Data API just add data-dismiss = "alert" to your close button to automatically give an alert close functionality.

  • Through JavaScript − To terminate through JavaScript use the following syntax –


Example

The next instance shows the use of alert plugin via data attributes.

Alert plugin

Options


Present are no choices here.


Methods


The next are some useful methods for alert plugin −

Method

Description

Example

.alert()

This method wraps all alerts with close functionality.

$('#identifier').alert();
            

Close Method.alert('close')

To enable all alerts to be closed, add this method.

$('#identifier').alert('close');
            

Example


The next example shows the use of .alert() method –


alert method


Events


Resulting table lists the events to work with alert plugin. This event may be used to hook into the alert function.

Event

Description

Example

close.bs.alert

This event fires immediately when thecloseinstance method is called.

$('#myalert').bind('close.bs.alert', function () {
            
 // do something
            
})
            

closed.bs.alert

This event is fired when the alert has been closed (will wait for CSS transitions to complete).

$('#myalert').bind('closed.bs.alert', function () {
            
 // do something
            
})
            

Example


The next instance shows the alert plugin events –


Alter plugin events


All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Bootstrap Topics