jquery - 停止 twitter bootstrap carousel 循环导航

标签 jquery css twitter-bootstrap

在轮播导航中,我有 <a class="carousel-control right" href="#howToBuyCarousel" data-slide="next">&rsaquo;</a> .如果我已经在最后一张幻灯片上,请问我是否禁止转到下一张幻灯片。如果我在第一张幻灯片上也是如此,我想禁用向左转到最后一张幻灯片。

最佳答案

您可以通过在“幻灯片”事件处理程序中手动检查当前事件的幻灯片来实现此功能

//this function gets called whenever carousel slides

$('#myCarousel').bind('slide', function(){

   var idx = $('#myCarousel .item.active').index();



   if(idx == yourCarouselLength - 1){

     //you have reached the end

     var next = $('#yourCarouselNext');

     // make your button inactive and remove any click handlers if present (pseudocode)

     next.addClass('inactive');

     //or stop automatic cycling, or however you want your carousel to behave


   }else if(idx == 0){

     //you are at the start

     var prev = $('#yourCarouselPrev');

     // make your button inactive and remove any click handlers if present (pseudocode)

     prev.addClass('inactive');

     //or stop automatic cycling, or however you want your carousel to behave

   }


});

这里的 '#yourCarouselPrev''#yourCarouselNext' 是您的轮播导航按钮的 ID。

关于jquery - 停止 twitter bootstrap carousel 循环导航,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18842950/

相关文章:

html - 如何忽略 wordpress 主题中的 <p> CSS 规则?

javascript - 横幅旋转器的动态轮播指示器

css - 按钮组内的相对定位 Bootstrap 下拉列表

javascript - 使用 javascript/jquery 触发文件上传对话框

jquery - 滚动顶部和滚动左摇晃

jquery - 如何像谷歌表单一样将背景颜色中心向右和向左设置动画?

html - CSS "vertical-align: top"用于删除内联元素下方的底部空间 - 它是如何工作的?

jquery - ASP.NET jQuery 双列表框编辑和保存

php - 屏幕宽度改变时如何删除 scrow 跟随 javascript

css - Twitter Bootstrap navbar-fixed-bottom 自定义高度