twitter-bootstrap closing alert does not work

后端 未结 5 826
滥情空心
滥情空心 2021-01-04 06:25

I can\'t get it to work. When I click the close button, nothing happens.

here\'s the code:

 
相关标签:
5条回答
  • 2021-01-04 06:41

    Edited from Shail that just changing from alert-error to alert-danger

    <div class=" alert alert-danger alert-block" style="width:200px">
         <button class="close" data-dismiss="alert">&times;</button>
         <span>
                 Before you can continuelds
                 highlighted below.
         </span>
    </div>
    

    Jsfiddle Demo

    0 讨论(0)
  • 2021-01-04 06:42

    Please include jquery library

    <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
    

    and It should work

    Jsfiddle Demo

    0 讨论(0)
  • 2021-01-04 06:54

    I've sorted it out.

    Instead of using a button, I'm now using a span, so the form doesn't get submitted:

            <span class="close" data-dismiss="alert">&times;</span>
    

    thanks for your help

    0 讨论(0)
  • 2021-01-04 06:57

    May be you forget to reference this:

    <script src="http://twitter.github.com/bootstrap/assets/js/jquery.js"></script>
    

    I had same problem. I added it, and it worked.

    0 讨论(0)
  • 2021-01-04 06:58

    It appears that the order in which you include the Javascript sources is important. First load jQuery, then the Bootstrap Javascript.

    E.g. This fails:

    <script src="/js/vendor/bootstrap.min.js"></script>
    <script src="/js/vendor/jquery-1.9.1.min.js"></script>
    

    and this works:

    <script src="/js/vendor/jquery-1.9.1.min.js"></script>
    <script src="/js/vendor/bootstrap.min.js"></script>
    

    You'll also see this in the example templates. From the Hero template:

    [...]
    <script src="/../assets/js/jquery.js"></script>
    <script src="/../assets/js/bootstrap-transition.js"></script>
    <script src="/../assets/js/bootstrap-alert.js"></script>
    [...]
    
    0 讨论(0)
提交回复
热议问题