Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Automatically slider slider button
- */
- // cache a reference to the tabs
- var tabContainer = $('#tabs');
- var tabs = $('#tabs li');
- // on click to tab, turn it on, and turn previously-on tab off
- tabs.click(function() {
- $(this).addClass('on').siblings('.on').removeClass('on');
- });
- // auto-rotate every 5 seconds
- var slideInterval;
- function initiateSlideInterval() {
- slideInterval = setInterval(function() {
- // get currently-on tab
- var onTab = tabs.filter('.on');
- // click either next tab, if exists, else first one
- var nextTab = onTab.index() < tabs.length - 1 ? onTab.next() : tabs.first();
- nextTab.click();
- }, 5000);
- }
- initiateSlideInterval();
- tabContainer.mouseover(function() {
- clearInterval(slideInterval)
- });
- tabContainer.mouseout(function() {
- initiateSlideInterval();
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement