2014-08-29 104 views

回答

11

wrap选项设置为false会使传送带自动停止循环。

$('#myCarousel').carousel({ 
    interval: 1000, 
    wrap: false 
}); 

此外,如果你想隐藏的左,右控制时,旋转木马是表示第一/最后一张幻灯片,你可以做到这一点的方法:

$('#myCarousel').on('slid.bs.carousel', '', function() { 
    var $this = $(this); 

    $this.children('.carousel-control').show(); 

    if($('.carousel-inner .item:first').hasClass('active')) { 
    $this.children('.left.carousel-control').hide(); 
    } else if($('.carousel-inner .item:last').hasClass('active')) { 
    $this.children('.right.carousel-control').hide(); 
    } 

}); 

DEMO

+4

同样地,你可以在传送带的HTML中使用'data-wrap =“false”'。 – cvrebert 2014-08-30 01:31:30

相关问题