Created
February 28, 2018 06:24
-
-
Save nhatnx/2851d132d524c6a9dcd98e0a1773a6b7 to your computer and use it in GitHub Desktop.
Break a jQuery each Loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// To break a <var>$.each</var> loop, you have to <var>return false</var> in the loop callback. | |
// Returning <var>true</var> skips to the next iteration, equivalent to a <var>continue</var> in a normal loop. | |
$.each(array, function(key, value) { | |
if(value === "foo") { | |
return false; | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment