Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alert dismissing using Twitter Bootstrap is not working?

I'm using Google Chrome.
Using Twitter Bootstrap, I want to add a simple alert, unfortunately the alert is not dismissing when the x is pressed!

Here's my code based on alert documentation:

<!DOCTYPE html>
<html>
  <head>
    <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
    <!-- Bootstrap -->
    <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
  </head>
  <body>    
    <div class="alert">
        <button type="button" class="close" data-dismiss="alert">×</button>
        <strong>Warning!</strong> Best check yo self, you're not looking too good.
    </div>      
  </body>
</html>

And I also tried:

<!DOCTYPE html>
  <html>
    <head>
      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js" type="text/javascript"></script>
      <!-- Bootstrap -->
      <link href="css/bootstrap.min.css" rel="stylesheet" media="screen">
    </head>
    <body>    
    <div class="alert">
        <a href="#" class="close" data-dismiss="alert">×</a>
        <strong>Warning!</strong> Best check yo self, you're not looking too good.
    </div>      
    </body>
  </html>

What is missing to make it dismiss ?

like image 784
Ashraf Bashir Avatar asked Nov 22 '12 11:11

Ashraf Bashir


People also ask

How do I automatically dismiss bootstrap alert?

Closing Alerts To close the alert message, add a . alert-dismissible class to the alert container. Then add class="close" and data-dismiss="alert" to a link or a button element (when you click on this the alert box will disappear).

Which bootstrap 4 class can be used to create successful alert?

Bootstrap 4 provides an easy way to create predefined alert messages. Alerts are created with the . alert class, followed by one of the eight contextual classes .

What is a bootstrap alert?

Bootstrap Alerts are used to provide an easy way to create predefined alert messages. Alert adds a style to your messages to make it more appealing to the users. There are four classes that are used within <div> element for alerts. .alert-success.


1 Answers

Thanks to davidkonrad's comment.
The solution is trivial, by adding:

    <script src="js/bootstrap.min.js"></script>
like image 191
Ashraf Bashir Avatar answered Sep 29 '22 04:09

Ashraf Bashir