Home >Web Front-end >JS Tutorial >Exit and continue the next loop in js and jquery_javascript skills
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); }
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