1、for循环中我们使用continue;终止本次循环计入下一个循环,使用break终止整个循环。
2、而在jquery中 $.each则对应的使用return true 和return false。
eg:
<script> $(function(){ for(var i=0;i<10;i++){ if(i%2==0)continue; if(i==7)break; document.write(i+"<br>"); } var json = [ {"id":"1","tagName":"11"}, {"id":"2","tagName":"22"}, {"id":"3","tagName":"33"}, {"id":"4","tagName":"44"}, {"id":"5","tagName":"55"}, {"id":"6","tagName":"66"}, {"id":"7","tagName":"77"}, {"id":"8","tagName":"88"} ]; $.each(json, function(idx, obj) { if(obj.id%2==0)return true; if(obj.id==7)return false; document.write(obj.tagName+"<br>"); }); }); </script>