Bootstrap Carousel [closed]

北战南征 提交于 2019-12-24 02:25:24

问题


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.


回答1:


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.

Example

$('body').on('slid', function (e) {
  //do stuff in here
});


来源:https://stackoverflow.com/questions/11485327/bootstrap-carousel

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!