Skip to content

Instantly share code, notes, and snippets.

@TastyToast
Created November 1, 2012 20:57
Show Gist options
  • Save TastyToast/3996489 to your computer and use it in GitHub Desktop.
Save TastyToast/3996489 to your computer and use it in GitHub Desktop.
Fade images in sequentially
(function() {
// Hide the elements initially
var lis = $('li').hide();
// When some anchor tag is clicked. (Being super generic here)
$('a').click(function() {
var i = 0;
// FadeIn each list item over 200 ms, and,
// when finished, recursively call displayImages.
// When eq(i) refers to an element that does not exist,
// jQuery will return an empty object, and not continue
// to fadeIn.
(function displayImages() {
lis.eq(i++).fadeIn(200, displayImages);
})();
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment