为什么bootstrap.js没有加载?

时间:2014-05-27 10:09:14

标签: javascript jquery twitter-bootstrap

我在JSfiddle中尝试了以下代码 - 但是,这在我自己的本地计算机上不起作用。

可能是什么原因?

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
<script href='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js'></script>
<script src="http://code.jquery.com/jquery-1.9.1.js"></script>    

<input type="button" id="loading-example-btn" data-loading-text="Loading..." class="btn btn-primary" value = "loading state">

<script>    
  $('#loading-example-btn').click(function () {
      var btn = $(this)
      btn.button('loading')    
  });
</script>

2 个答案:

答案 0 :(得分:0)

脚本标记没有href属性。它包含src属性。

所以

<script src='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js'> </script>

会奏效。

答案 1 :(得分:-1)

您必须在doucment.ready函数内编写jQuery脚本,并且在booststrap.js之后加载了jQuery库,这应该在

之前加载

试试这个:

<script src="http://code.jquery.com/jquery-1.9.1.js"></script>

<link rel="stylesheet" href="http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/css/bootstrap-combined.min.css">
<script src='http://netdna.bootstrapcdn.com/twitter-bootstrap/2.3.2/js/bootstrap.min.js'></script>

<input type="button" id="loading-example-btn" data-loading-text="Loading..." class="btn btn-primary" value = "loading state">    

<script>

    $(document).ready(function()
    {

      $('#loading-example-btn').click(function () {
        var btn = $(this)
        btn.button('loading')

      });
    });
</script>