0

我正在尝试使用 jquery bootstrap carousel 设置图像滑块。

似乎很好,只是滑块不起作用。当我单击“下一步”箭头时,图像不会改变。

我究竟做错了什么?

最良好的祝愿,

费萨尔


JAVASCRIPT 文件

<script src="//ajax.googleapis.com/ajax/libs/jquery/1.6.1/jquery.min.js"></script>
<script src="/assets/jquery.js"></script>
<script src="/assets/bootstrap-carousel.js"></script>

我称之为引导轮播的脚本

<script>
$(function () {
//    $('.carousel').carousel({ interval: 2000 })

    $('#myCarousel').carousel()
        });
</script>

看法

<div id="myCarousel" class="carousel">
 <!-- Carousel items -->
 <div class="carousel-inner">
   <div class="active item">
     …&lt;img src="/assets/us1.jpg" style="height="200", width="200">
   </div>
   <div class="item">
     …&lt;img src="/assets/us2.jpg" style="height="200", width="200">
   </div>
  </div>

  <!-- Carousel nav -->
  <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
  <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>
4

1 回答 1

1

我认为您需要在下一个/上一个链接中引用轮播的 ID,如下所示:

编辑:您有很多错别字,您的图像样式无效。而且通常我什至不必在 js 中调用轮播,我只需给它们所有唯一的 id。

我会仔细看看文档http://twitter.github.com/bootstrap/javascript.html#carousel

<div id="myCarousel" class="carousel">

<!-- Carousel items -->
<div class="carousel-inner">
  <div class="active item">
    <img src="/assets/us1.jpg" height="200" width="200">
  </div>
  <div class="item">
    <img src="/assets/us2.jpg" height="200" width="200">
  </div>
</div>

<!-- Carousel nav -->
<a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>
</div>

好吧,将其复制粘贴到您的视图中...如果您加载了 jquery,它应该可以开箱即用。

  <div id="myCarousel" class="carousel slide">
    <div class="carousel-inner">
      <div class="item active">
        <img src="assets/img/bootstrap-mdo-sfmoma-01.jpg" alt="">
        <div class="carousel-caption">
          <h4>First Thumbnail label</h4>
          <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
        </div>
      </div>
      <div class="item">
        <img src="assets/img/bootstrap-mdo-sfmoma-02.jpg" alt="">
        <div class="carousel-caption">
          <h4>Second Thumbnail label</h4>
          <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
        </div>
      </div>
      <div class="item">
        <img src="assets/img/bootstrap-mdo-sfmoma-03.jpg" alt="">
        <div class="carousel-caption">
          <h4>Third Thumbnail label</h4>
          <p>Cras justo odio, dapibus ac facilisis in, egestas eget quam. Donec id elit non mi porta gravida at eget metus. Nullam id dolor id nibh ultricies vehicula ut id elit.</p>
        </div>
      </div>
    </div>
    <a class="left carousel-control" href="#myCarousel" data-slide="prev">&lsaquo;</a>
    <a class="right carousel-control" href="#myCarousel" data-slide="next">&rsaquo;</a>
  </div>
于 2012-05-08T08:27:39.143 回答