Skip to content

Instantly share code, notes, and snippets.

@nhatnx
Created February 28, 2018 06:24
Show Gist options
  • Save nhatnx/2851d132d524c6a9dcd98e0a1773a6b7 to your computer and use it in GitHub Desktop.
Save nhatnx/2851d132d524c6a9dcd98e0a1773a6b7 to your computer and use it in GitHub Desktop.
Break a jQuery each Loop
// 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