我想将最后一个滑块显示为bootstrap carousal中的第一个项目。我有x个幻灯片(动态幻灯片)。我想在load.now上加载最后一个幻灯片它显示加载时的第一个项目。
$(slick).on('afterChange', myFunctionName);
答案 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">‹</a>
<a class="carousel-control right" href="#myCarousel" data-slide="next">›</a>
</div>
</div>
&#13;