Home > Web Front-end > JS Tutorial > body text

Exit and continue learning records of loops in js and jquery_javascript skills

WBOY
Release: 2016-05-16 16:36:49
Original
1089 people have browsed it

As a parallel importer, even if you learn 1 1 = 3, you still have to record it! Wrong, it’s 2

Learning record:

in js
for(var i=1;i<5;i++){
if(i==3){
break; // 使用break,弹出2次提示分别为1,2;如果使用continue,则会弹出3次,分别是1,2,4
}
alert(i);
}
Copy after login

Loop, to exit the loop, use break; to exit the current loop and continue the next loop, use continue

To implement break in the each() method in jquery, use return false; to continue, use return true

Related labels:
source:php.cn
Statement of this Website
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
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template