加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 综合聚焦 > 服务器 > 安全 > 正文

twitter-bootstrap – 停止bootstrap轮播以在幻灯片结束时循环

发布时间:2020-12-18 00:28:15 所属栏目:安全 来源:网络整理
导读:我想这样,当我按下旋转木马上的下一个按钮时,如果它已到达滑动的末端,则不要环绕并返回到第一张幻灯片.在bootstrap 3中有一个简单的方法吗? 解决方法 将wrap选项设置为false会使轮播停止自动循环. $('#myCarousel').carousel({ interval: 1000,wrap: false}
我想这样,当我按下旋转木马上的下一个按钮时,如果它已到达滑动的末端,则不要环绕并返回到第一张幻灯片.在bootstrap 3中有一个简单的方法吗?

解决方法

将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

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读