Possible Duplicate:
Nested jQuery.each() - continue/break
Here is my code:
var steps = $("div#f");
steps.each(function () {
var s = $(this);
var cs = $(this).find(".Cm");
cs.each(function () {
var tc = $(this);
var err = tc.attr("h");
if (err == false) {
this.c = err;//this.c is a global variable
return this.c;
break;//here is where the error is being thrown
}
else {
this.c = {"Eval": err, "S": s, "Cm": tc};
return this.c;
}
});
});
I'm using an .each()
iteration to collect values. I thought it functioned like a loop so i thought id use a break
statement to break out. This is throwing an "illegal" error. Does anyone know how to break out of an each
iteration?
use return false
. Take a look at this resource: http://gavinroy.com/jquery-tip-how-to-break-out-of-each
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With