bootstrap过渡到加载时的最后一个滑块

时间:2017-06-02 05:36:04

标签: javascript jquery html carousel

我想将最后一个滑块显示为bootstrap carousal中的第一个项目。我有x个幻灯片(动态幻灯片)。我想在load.now上加载最后一个幻灯片它显示加载时的第一个项目。

$(slick).on('afterChange', myFunctionName);

1 个答案:

答案 0 :(得分:2)

active课程添加到最后一项,例如



$('#myCarousel').carousel({
  interval: 4000,
});
$('#myCarousel').find('.item:last').addClass('active')
   

<link href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css" rel="stylesheet"/>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.js"></script>
<div id="myCarousel" class="carousel slide" style="width:450px">
  <!-- Carousel items -->
  <div class="carousel-inner">
    <div class="item"><img alt="img/IMG_2.jpg"></div>
    <div class="item"><img alt="img/IMG_3.jpg"></div>
    <div class="item"><img alt="img/IMG_1.jpg"></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>
</div>
&#13;
&#13;
&#13;