Created
March 20, 2012 12:56
-
-
Save gpassarelli/2135086 to your computer and use it in GitHub Desktop.
jQuery: Cycle Through a List
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
$(document).ready(function() { | |
var j = 0; | |
var delay = 2000; //millisecond delay between cycles | |
function cycleThru(){ | |
var jmax = $("ul#cyclelist li").length -1; | |
$("ul#cyclelist li:eq(" + j + ")") | |
.animate({"opacity" : "1"} ,400) | |
.animate({"opacity" : "1"}, delay) | |
.animate({"opacity" : "0"}, 400, function(){ | |
(j == jmax) ? j=0 : j++; | |
cycleThru(); | |
}); | |
}; | |
cycleThru(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment