Bootstrap > Alerts

Closed alert using javascript in Bootstrap

How to display alert on close using javascript in Bootstrap

Alert using javascript

        $(document).ready(function () {
            $("#success").on('', function () {
                alert("This is closed");
<div class="container-fluid">
    <div class="alert alert-success" id="success">
        <a href="#" class="close" data-dismiss="alert" aria-label="close">&times;</a>
        <b>Am TechFunda</b>
  • In the above code snippet we have defined how to display a closed alert using javascript
  • We have div section with class value as container-fluid  and we have the div with class value as alert alert-success and id as success
  • In the next line we have the anchor tag with class value as close, data-dismiss=alert and aria-label as close
  • In the script function we have the id as success which we have given as #success .on displays the closed alert function with given value as This is closed 



 Views: 4851 | Post Order: 18

Write for us

Hosting Recommendations