jquery - Get return from javascript anonymous funcion in each loop(s) -
i've never worked js before , faced problem, how can next?
function test() { $(xml).find("strengths").each(function() { $(this).each(function() { (if condition) { //i want break out both each loops @ same time here. // , main function too! } }); }); }
i understand stop 1 loop need return false
. if have nested? , how return main function?
thanks all!
you use 2 variables:
function test() { var tocontinue = true, toreturn; $(xml).find("strengths").each(function() { $(this).each(function() { if("some condition") { toreturn = {something: "sexy there!"}; return tocontinue = false; } }); return tocontinue; }); if(toreturn) return toreturn; //else stuff; }
Comments
Post a Comment