Skip to content

Instantly share code, notes, and snippets.

Created January 21, 2018 12:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anonymous/f22c73ea996f52e56dafdf3b779328ac to your computer and use it in GitHub Desktop.
Save anonymous/f22c73ea996f52e56dafdf3b779328ac to your computer and use it in GitHub Desktop.
Auto Switch Tab with interval
jQuery( document ).ready(function () {
var timeInterval, tabCount = 0, currnetIndex = 1;
tabCount = jQuery( '.elegant-tabs-list-container li' ).length;
changeTabIndex();
timeInterval = setInterval( function () { changeTabIndex(); }, 4 * 1500);
function changeTabIndex() {
if ( currnetIndex > tabCount ) {
currnetIndex = 1;
}
var currentAncorObj = jQuery( '.elegant-tabs-list-container' ).find( 'li' ).eq( currnetIndex - 1 );
jQuery( currentAncorObj ).trigger( 'click' );
currnetIndex++;
};
jQuery( '.elegant-tabs-list-container li' ).mouseenter( function () {
clearInterval( timeInterval );
}).mouseleave( function () {
timeInterval = setInterval( function () { changeTabIndex(); }, 4 * 1500);
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment