Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
146
rated 0 times [  153] [ 7]  / answers: 1 / hits: 23372  / 15 Years ago, wed, march 24, 2010, 12:00:00

I have such code:



function allValid() {
$('input').each(function(index) {
if(something) {
return false;
}
});

return true;
}


which always returns true as return false; affects anonymous inner function. Is there an easy way to call outer function's return?



PS. I am not looking for a workaround, just want to know the answer to original question. If the answer is not possible it is fine.


More From » jquery

 Answers
34

Yeah, store it in a local variable.



function allValid() {
var allGood = true;
$('input').each(function (index) {
if (something) {
allGood = false;
}
});

return allGood;
}

[#97256] Saturday, March 20, 2010, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
parisc

Total Points: 438
Total Questions: 119
Total Answers: 119

Location: Turkmenistan
Member since Sat, Apr 16, 2022
2 Years ago
;