2009年3月24日 星期二

jQuery each迴圈中的continue及break

continue :return true;
break :return false;
也可以利用return即可跳出jQuery

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.

沒有留言:

張貼留言