Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
// John Tantalo
jQuery.fn.chain = function (fn)
{
var self = this;
return function ()
{
if (!self.size()) return;
fn(self.eq(0), self.slice(1).chain(fn));
}
}
// example
jQuery("foo").click(jQuery("bar").chain(fn));
function fn(element, callback)
{
// some crap with element
if (callback) callback();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.