Skip to content

Instantly share code, notes, and snippets.

@c4urself
Created October 5, 2012 20:33
Show Gist options
  • Save c4urself/3842214 to your computer and use it in GitHub Desktop.
Save c4urself/3842214 to your computer and use it in GitHub Desktop.
Recursively hide a set of matched elements
// Self-calling named function which takes an array of elements
// calls an event on the first element in that array and passes
// the rest of the array to that function recursively until the
// array is empty. The recursive call is done in the callback of
// the previous element's event so that it nicely waits for the
// previous element to be done.
(function hidenext(jq) {
jq.eq(0).fadeOut("fast", function(){
(jq=jq.slice(1)).length && hidenext(jq);
});
})($('div#bodyContent a'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment