Home >Web Front-end >JS Tutorial >jquery $.each and for how to jump out of the loop and terminate this loop_jquery

jquery $.each and for how to jump out of the loop and terminate this loop_jquery

WBOY
WBOYOriginal
2016-05-16 17:21:081273browse

How to terminate this loop or jump out of the loop in jquery? After checking some information and testing, I found that the following method can be used

1. We use continue in the for loop; terminating this loop will be counted as the next loop, and using break to terminate the entire loop.
2. In jquery, $.each uses return true and return false accordingly.

break can jump out of the switch...case statement and continue executing the content after the switch statement. The break statement can also jump out of the loop, that is, end the execution of the loop statement.

The function of the continue statement is to end this loop and then judge whether to execute the loop next time.

The difference between continue and break is: break is to end the loop completely, while continue is to end the current loop.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn