Skip to content

Instantly share code, notes, and snippets.

@gpassarelli
Created March 20, 2012 12:56
Show Gist options
  • Save gpassarelli/2135086 to your computer and use it in GitHub Desktop.
Save gpassarelli/2135086 to your computer and use it in GitHub Desktop.
jQuery: Cycle Through a List
$(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