【问题标题】:Why is this bootstrap script not responding/working?为什么这个引导脚本没有响应/工作?
【发布时间】:2016-10-17 17:20:53
【问题描述】:

我有一个引导滑块,当我单击控件时,它不滑动,甚至没有响应。我可以看到第一张图片,但无论我点击哪里,我都无法访问其他图片。下面的这个脚本对你有用吗?

    <head>
<!-- Latest compiled and minified CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css">

<!-- Latest compiled and minified JavaScript -->
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js" ></script>
<script src="js/jquery.js"></script>
<script src="js/jquery-migrate-1.1.1.js"></script>
<script src="js/script.js"></script>

    </head>


<body>
    <div id="carousel-example-generic" class="carousel slide" data-ride="carousel">
  <!-- Indicators -->
  <ol class="carousel-indicators">
    <li data-target="#carousel-example-generic" data-slide-to="0" class="active"></li>
    <li data-target="#carousel-example-generic" data-slide-to="1"></li>
    <li data-target="#carousel-example-generic" data-slide-to="2"></li>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="http://placehold.it/450x350" alt="Slide 1">
      <div class="carousel-caption">
        Caption Slide 1
      </div>
    </div>
    <div class="item">
      <img src="http://placehold.it/450x350" alt="Slide 2">
      <div class="carousel-caption">
        Caption Slide 2
      </div>
    </div>
    <div class="item">
      <img src="http://placehold.it/450x350" alt="Slide 3">
      <div class="carousel-caption">
        Caption Slide 3
      </div>
    </div>        
  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left" aria-hidden="true"></span>
    <span class="sr-only">Previous</span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right" aria-hidden="true"></span>
    <span class="sr-only">Next</span>
  </a>
</div>
</body>

【问题讨论】:

  • 您在浏览器的控制台中遇到什么错误?而且不是必须在Bootstrap之前包含jQuery吗?
  • 把jquery放在上面和下面添加bootstrap js
  • @KinshukLahiri:就这么简单。谢谢它有效。
  • Protip:保留JS console open。一看就会马上给你答案。
  • @BicMitchun 在回答中为您添加了详细信息:)

标签: jquery twitter-bootstrap bootstrap-carousel


【解决方案1】:

详细说明:

Bootstrap 是一个附加了一些 jquery 事件的 js 文件。如果您将 jquery 脚本放在它下面,则不会附加事件。因此,您需要始终在上方添加 jquery 以附加事件。

希望这个解释有帮助:)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-10-20
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2023-02-20
    相关资源
    最近更新 更多