All modern web application uses alerts to show messages to the user. These alerts have a close button to close them or can be closed automatically using Twitter Bootstrap. In this post, we will create automatically closing of alerts using twitter Bootstrap.
Basic idea is to use jQuery setTimeout() method to close the alert after specified time.
Note: Delay is defined in milliseconds. 1 second is equal to 1000 milliseconds.
Example 1: In this example, alert is accessed in script using the id and then alert is closed after 5 seconds.
Example 2: In this example, alert is accessed in script using it’s class and alert closes after 2 seconds.
- How to automatically close all collapsible elements inside of the accordion when closing the accordion?
- Bootstrap (Part-7) | Alerts , Wells, Pagination and Pager
- Bootstrap 4 | Alerts
- Bootstrap 5 Alerts
- How to use Bootstrap modal for YouTube videos and play automatically ?
- How to use complex HTML with twitter Bootstrap tooltip using jQuery ?
- How to change the width and height of Twitter Bootstrap's tooltips?
- How to Check Twitter Bootstrap is Loaded or not ?
- How to use modal closing event in Twitter Bootstrap ?
- How to handle the modal closing event in Twitter Bootstrap?
- How to hide element on small devices in Twitter Bootstrap ?
- Data-toggle attributes in Twitter Bootstrap
- How to close sidebar by default using Bootstrap ?
- How to scroll automatically to the Bottom of the Page using jQuery?
- How to call a function automatically after waiting for some time using jQuery?
- How to scroll automatically to a particular element using JQuery?
- How to get focused a button automatically when the page load using HTML ?
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to email@example.com. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.