Created
December 1, 2009 17:55
-
-
Save tantalor/246484 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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