Home  >  Article  >  Web Front-end  >  js和jquery中循环的退出和继续下一个循环_javascript技巧

js和jquery中循环的退出和继续下一个循环_javascript技巧

WBOY
WBOYOriginal
2016-05-16 16:37:501359browse

作为水货,就是学会了1+1=3也要记录一下!错了,是2

学习记录:

js中的

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

循环,退出循环,使用break;退出当前循环继续下一个循环,使用continue

jquery中的each()方法中要实现break,使用return false;continue,使用return true

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