jQuery: How to exit $.each loop

If you wrote your code and tried using the “break;” command to exit the “each loop” you may have noticed that it’s not working, thus is why you’re here.

The “break” command actually acts exactly what the “continue” command does in Javascript. The “continue” command skips the current iteration and continues to the next one.

To exit jQuery’s $.each loop, you have to use the “return false;” method, like so:

Happy coding 🙂

Leave a Reply

Your email address will not be published. Required fields are marked *