jQuery.each()ループから抜けるには?
jQuery、javaScriptのループから抜けるには、
breakがよく、使われるが、どうやらjQueryのeach()ループから抜けるには、
returnでやらないといけない。
jQueryの仕様では、下記のように書いてある。
「
We can break the $.each() loop at a particular iteration by making the callback function return false.
Returning non-false is the same as a continue statement in a for loop;
it will skip immediately to the next iteration.
」
なので、returnを使いましょう!
jQuery、javaScriptのループから抜けるには、
breakがよく、使われるが、どうやらjQueryのeach()ループから抜けるには、
returnでやらないといけない。
jQueryの仕様では、下記のように書いてある。
「
We can break the $.each() loop at a particular iteration by making the callback function return false.
Returning non-false is the same as a continue statement in a for loop;
it will skip immediately to the next iteration.
」
なので、returnを使いましょう!
コメント
コメントを投稿