Skip to content

Instantly share code, notes, and snippets.

@daronspence
Last active August 29, 2015 14:06
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save daronspence/cf8d16039373d82018d6 to your computer and use it in GitHub Desktop.
Save daronspence/cf8d16039373d82018d6 to your computer and use it in GitHub Desktop.
jQuery Fade Each & Repeat
(function($) {
function fadeloop(){ // loops through elements and fades them sequentially
$('.my-element').each(function( index, element){
$(element).delay(index*4000).fadeIn(500).delay(3000).fadeOut(500);
});
}
function fade(){ // calls itself to repeat
window.setTimeout(fadeloop, 0);
window.setTimeout(fade, 16000);
}
fade(); // Starts the initial fade
})(jQuery);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment