javascript - break from .each jquery -
how can break jquery each out return false.
consider following
function check_quantity(){ var _q = $(".quantity"); _q.each( function(){ if( some_condition ){ break; // want break here , need homecoming true instead of false // reasons there no way go on } } ); homecoming false; // if status failed } is there work around ?
without changing function, set flag true in loop if want in it.
function check_quantity(){ var ret = false; var _q = $(".quantity"); _q.each( function(){ if( some_condition ){ ret = true; // want break here , need homecoming true instead of false // reasons there no way go on } } ); homecoming ret; // if status failed } javascript jquery
No comments:
Post a Comment