Last active
August 29, 2015 14:06
-
-
Save daronspence/cf8d16039373d82018d6 to your computer and use it in GitHub Desktop.
jQuery Fade Each & Repeat
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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