I am looking to have the Twitter Bootstrap tabs change on a timed sequence. I am using them kind of like a carousel. I would like the tabs to change to the next one every 10 seconds.
Here is an example: http://library.buffalo.edu
Click on the news stories to see what I mean. Any help would be appreciated.
one way of catching the hover event. it really depends on what element you are trying to catch to stop the cycling. the tabs or the tab content. this hooks to the tabs.
Control user frequently clicks on navs manually, Here is a fiddle try to click multiple time on navs
Something like this will create a never-ending carousel loop; it will cycle through all tabs and return to the first one after it reaches the last (change
#yourTabWrapper
to be an appropriate selector for whatever contains your tab markup):All we're doing is finding the active tab, then triggering the
click
event on the next tab in the list. If there is no next tab, we trigger theclick
event on the first tab. Note that the event is actually triggered on thea
, not theli
.Now, if you want to add logic to pause or reset the interval when the user either hovers over or manually clicks a tab, that will need to be added separately, and you would use
clearInterval(tabCarousel)
to stop the cycling.Here is a basic demo:
--- jsFiddle DEMO ---
Fixed the AppSol solution:
Another nice option is to pause the slideshow when a tab is clicked:
I have added the clock to the Pallab's code. So that even if different tabs are clicked before the timeout period which is 10 seconds in my case the current tab will be shown for 10 seconds and tabs will automatically tab after 5 seconds. I am a beginner so please bear with my coding.
You have to click 2 or more tabs , one tab at at a time , in less than 10 seconds