|
Continue and break in a jQuery loop |
|
Facts -
HTML and Javascript
|
|
Sunday, 21 December 2008 09:49 |
|
jQuery loops are implemented by calling the each function on a jQuery object. The argument of
the each function is another function. This function argument is executed for each element in the
jQuery array. This is different from a normal javascript loop and therefore the break and continue
statements do not work in a jQuery loop.
Fortunately there is another way for breaking and continuing a jQuery loop. You can break a
jQuery loop by returning false in the function argument. A continue can be implemented by just
doing a return without specifying a return value or by returning any other value than false.
|