带分页的引导旋转木马-当使用旋转木马控件时,当前幻灯片在导航中不活动
Bootstrap carousel with pagination - current slide not active in navigation when using carousel control
我做了一个carousel,用分页代替圆点作为导航。
当您使用页码进行导航时,它工作得很好,并且添加了活动类。当你使用控件(左或右)导航时,它会正确地转到下一个/前页,但是导航中的活动类不会改变。
有问题的页面在这里
它来自这个jsfiddle,使用下面的代码:http://jsfiddle.net/juddlyon/Q2TYv/10/
就我所知,我遵循了jsfiddle中的示例。出了什么问题?
// invoke the carousel
$('#myCarousel').carousel({
interval: false
});
/* SLIDE ON CLICK */
$('.carousel-linked-nav > li > a').click(function() {
// grab href, remove pound sign, convert to number
var item = Number($(this).attr('href').substring(1));
// slide to number -1 (account for zero indexing)
$('#myCarousel').carousel(item - 1);
// remove current active class
$('.carousel-linked-nav .active').removeClass('active');
// add active class to just clicked on item
$(this).parent().addClass('active');
// don't follow the link
return false;
});
/* AUTOPLAY NAV HIGHLIGHT */
// bind 'slid' function
$('#myCarousel').bind('slid', function() {
// remove active class
$('.carousel-linked-nav .active').removeClass('active');
// get index of currently active item
var idx = $('#myCarousel .item.active').index();
// select currently active item and add active class
$('.carousel-linked-nav li:eq(' + idx + ')').addClass('active');
});
您使用的是较新的bootstrap版本。事件"slid
"重命名为"slid.bs.carousel
"
所以绑定到新事件将为你工作。
$('#myCarousel').bind('slid.bs.carousel', function() {
// remove active class
$('.carousel-linked-nav .active').removeClass('active');
// get index of currently active item
var idx = $('#myCarousel .item.active').index();
// select currently active item and add active class
$('.carousel-linked-nav li:eq(' + idx + ')').addClass('active');
});
相应的引导文档链接:http://getbootstrap.com/javascript/#carousel-events
相关文章:
- 结束时停止推特引导旋转木马's幻灯片
- Bootstrap 3 旋转木马白色背景滑动时滑动下方的幻灯片
- 带褪色+滑动的引导旋转木马幻灯片
- 光滑的旋转木马如何将当前幻灯片作为 dom 或 jquery 对象获取
- OWL旋转木马移动+/-5张幻灯片
- 奇怪的引导程序旋转木马问题.第一张幻灯片最初没有加载
- 从引导程序旋转木马中的特定幻灯片开始
- 在基于DOM元素而非索引的引导旋转木马中跳到另一张幻灯片
- Angular Js需要多幻灯片旋转木马
- jQuery文本大小调整插件只适用于第一张幻灯片的引导旋转木马
- 如何去特定的幻灯片在左边雪佛龙点击引导旋转木马,而不是直接去上一张幻灯片
- Bxslider将next按钮绑定到旋转木马中的下一张幻灯片
- 引导旋转木马-如何得到计数幻灯片
- Bootstrap 3旋转木马显示空白幻灯片在结束
- 带分页的引导旋转木马-当使用旋转木马控件时,当前幻灯片在导航中不活动
- 在角度引导旋转木马上设置活动幻灯片
- 圆滑的旋转木马隐藏最后一张幻灯片期间调整大小,圆滑的goto不工作如预期
- 将CSS应用于旋转木马幻灯片上的另一个span
- 推特引导旋转木马幻灯片与js代码
- 添加效果的引导旋转木马幻灯片