Skip to content

Instantly share code, notes, and snippets.

@dirkschmid
Forked from gpassarelli/gist:2135086
Created March 31, 2012 07:50
Show Gist options
  • Select an option

  • Save dirkschmid/2260667 to your computer and use it in GitHub Desktop.

Select an option

Save dirkschmid/2260667 to your computer and use it in GitHub Desktop.
jQuery: Cycle Through a List
ul#cyclelist {position:relative;overflow:hidden;}
ul#cyclelist li {opacity:0;position:absolute;}
$(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