From: John Resig Date: Thu, 12 Oct 2006 16:37:01 +0000 (+0000) Subject: Added code to short-circuit a .each() loop. X-Git-Url: http://git.asbjorn.it/?a=commitdiff_plain;h=edb54ef7334831d47591569316beb69e8ad717d6;p=jquery.git Added code to short-circuit a .each() loop. --- diff --git a/src/jquery/jquery.js b/src/jquery/jquery.js index 9edd758..8332f64 100644 --- a/src/jquery/jquery.js +++ b/src/jquery/jquery.js @@ -1384,10 +1384,10 @@ jQuery.extend({ each: function( obj, fn, args ) { if ( obj.length == undefined ) for ( var i in obj ) - fn.apply( obj[i], args || [i, obj[i]] ); + if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break; else for ( var i = 0; i < obj.length; i++ ) - fn.apply( obj[i], args || [i, obj[i]] ); + if ( fn.apply( obj[i], args || [i, obj[i]] ) === false ) break; return obj; },