使用Twitter Bootstrap的警报解雇不起作用?

时间:2012-11-22 11:29:40

标签: twitter-bootstrap alert dismiss

我正在使用Google Chrome。
使用Twitter Bootstrap,我想添加一个简单的提醒,不幸的是,当按下x时,alert并没有被忽略!

以下是基于alert文档的代码:

<!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>

我也尝试过:

<!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>

让它解散的缺失是什么?

2 个答案:

答案 0 :(得分:19)

感谢davidkonrad的评论。
通过添加:

,解决方案是微不足道的
    <script src="js/bootstrap.min.js"></script>

答案 1 :(得分:0)

我已经编写了一个small, customisable, jquery plugin注入一个正确形成的Bootstrap 3警报(有或没有关闭按钮,你需要它),只需要少量的烦恼,并允许你在关闭框后轻松地重新生成它。

有关用法,测试和示例,请参阅https://github.com/davesag/jquery-bs3Alert

相关问题