Advertisement
Guest User

Untitled

a guest
May 29th, 2015
297
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. jQuery(function() {
  2.  
  3. //cache a reference to the tabs
  4. var tabs = jQuery('.responsive-tabs__list li');
  5.  
  6. //on click to tab, turn it on, and turn previously-on tab off
  7. tabs.click(function() { jQuery(this).addClass('responsive-tabs__list__item--active').siblings('.responsive-tabs__list__item--active').removeClass('responsive-tabs__list__item--active'); });
  8.  
  9. //auto-rotate
  10. setInterval(function() {
  11.  
  12. //get currently-on tab
  13. var onTab = tabs.filter('.responsive-tabs__list__item--active');
  14.  
  15. //click either next tab, if exists, else first one
  16. var nextTab = onTab.index() < tabs.length-1 ? onTab.next() : tabs.first();
  17.  
  18. nextTab.click();
  19. }, 8000);
  20. });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement