引导轮播 [英] Bootstrap Carousel
问题描述
我正在使用引导程序制作轮播.但是问题是,我似乎无法弄清楚每次轮播进行循环时如何调用函数(这是指轮播的自动循环功能).有人对此有任何想法吗?
I am using bootstrap to make a carousel. The problem however is that I cant seem to figure out how I can call a function every time the carousel makes a cycle (with that I mean the automatic cycle function of the carousel). Anyone got any ideas for this?
我需要的地方是: 除了旋转木马以外,我所有的图片(来自旋转木马)都是大拇指,因此您拥有像相册之类的东西.然后,我可以单击那些拇指中的任何一个,然后直接转到它.然后,我将拇指设为活动"状态(基本上是黑色边框,而不是灰色边框),然后使上一个拇指(单击时处于活动状态的拇指)恢复正常.但是...当旋转木马到处转(看起来很棒)时,我想让活动拇指保持最新状态.为此,我唯一需要做的就是能够在轮播循环的同一时刻调用函数.
Where I need it for is the following: Except for the carousel I have all pictures (from the carousel) as thumbs, so you have something like a photo album. Then I can click on any of those thumbs and I go directly to it. Then I make the thumb 'active' (which is basically a black border instead of a grey one) and then I make the previous thumb (the one that was active when I clicked on it) back to normal. But... when the carousel is cycling around (which looks pretty awesome) I want to keep the active thumb up to date. The only thing that I need in order to do that, is being able to call a function on the same moment that the carousel makes a cycle.
推荐答案
在中找到Twitter Bootstrap Carousel插件的文档中,该轮播会触发两个您可以监听的事件,分别为slide
和slid
.尝试听这些事件之一,然后在回调中执行所需的代码.
As found in the documentation for the Twitter Bootstrap Carousel plugin, the carousel fires two events that you can listen for, slide
and slid
. Try listening to one of these events, and then executing the code you need in the callback.
$('body').on('slid', function (e) {
//do stuff in here
});
这篇关于引导轮播的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!