Bootstrap 3 Carousel可在本地运行,但不会在服务器

时间:2015-11-05 07:31:16

标签: javascript jquery html twitter-bootstrap

我有这个用于html

   <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">
    <div class="item active">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
    <div class="item">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
    <div class="item">
      <img src="http://placehold.it/1200x315" alt="...">
      <div class="carousel-caption">
          <h3>Caption Text</h3>
      </div>
    </div>
  </div>

  <!-- Controls -->
  <a class="left carousel-control" href="#carousel-example-generic" role="button" data-slide="prev">
    <span class="glyphicon glyphicon-chevron-left"></span>
  </a>
  <a class="right carousel-control" href="#carousel-example-generic" role="button" data-slide="next">
    <span class="glyphicon glyphicon-chevron-right"></span>
  </a>
</div> <!-- Carousel -->

我已将托管的jquery和本地bootstrap.js添加到html文件的头部

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="js/bootstrap.min.js"></script>

在轮播没有工作之后,我将jquery引用移动到html页面的底部,看看它是否会加载,因为html从上到下加载但仍然没有运气。关于如何让它工作的任何想法?我是JQuery的新手,所以请说明一点。

2 个答案:

答案 0 :(得分:2)

试试这个:

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/js/bootstrap.min.js"></script>

答案 1 :(得分:1)

检查jquery是否

if (typeof jQuery != 'undefined') {

alert("jQuery library is loaded!");

}否则{

alert("jQuery library is not found!");

}

并检查chrome hit f12 for developer mode并检查源代码是否正确加载了jquery和boostrap。如果发生某些错误,请检查控制台选项卡