【问题标题】:Twitter Bootstrap Carousel buttons not workingTwitter Bootstrap 轮播按钮不起作用
【发布时间】:2015-12-24 16:41:44
【问题描述】:

我正在尝试在我的网站中实现 bootstrap 3 轮播,但是左右滑动按钮不起作用,滑动点也是如此。谁能发现我的代码中的问题?

<!doctype html> 
<html>
<head>
    <script src="//code.jquery.com/jquery-1.11.2.min.js"></script>
    <script type="text/javascript" scr="js/bootstrap.js"></script>
    <link rel="stylesheet" type="text/css" href="css/bootstrap.css">
    <title>Test page! </title>
</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>
  </ol>

  <!-- Wrapper for slides -->
  <div class="carousel-inner" role="listbox">
    <div class="item active">
      <img src="img/deepcleaning1.jpg" alt="deepcleaning">
    </div>
    <div class="item">
      <img src="img/deepcleaning2.jpg" alt="deepcleaning2">
    </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>
</html>

【问题讨论】:

  • 你也可以发一个小提琴
  • 你可以尝试用这个 &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js"&gt;&lt;/script&gt; 替换 jquery 链接,有可能它没有按照你引用的方式找到 jquery
  • 检查一次控制台错误!!!

标签: javascript jquery html twitter-bootstrap twitter-bootstrap-3


【解决方案1】:

听起来与Bootstrap Carousel does not work类似的问题

那里的答案建议检查 javascript 错误,尤其是 jquery 的链接。似乎在 URL 中添加 http 或 https 可以解决此问题。

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

<script src="https://code.jquery.com/jquery-1.11.2.min.js"></script>

【讨论】:

    【解决方案2】:

    结果由于某种原因,jquery 链接不起作用...我所做的只是下载 jquery 文件并链接到它,而不是使用 API。像魅力一样工作。

    不知道为什么链接对我不起作用...

    【讨论】:

      猜你喜欢
      • 2012-04-16
      • 1970-01-01
      • 2012-09-03
      • 2023-03-23
      • 2013-06-25
      • 1970-01-01
      • 1970-01-01
      • 2023-01-25
      • 1970-01-01
      相关资源
      最近更新 更多