each实质上是一个for循环,那么能不能像普通的for循环那样break和continue呢?

参考http://bevisoft.iteye.com/blog/641195做了个实验,可以的,

代码如下:

  1. <meta http-equiv="Content-Type" content="text/html; charset=gbk" />
  2. <select id="branchName">
  3. <option value="10">北京分公司</option>
  4. <option value="11">天津分公司</option>
  5. <option value="12">河北分公司</option>
  6. <option value="13">山西分公司</option>
  7. </select>
  8. <script src="http://code.jquery.com/jquery-latest.min.js"></script>
  9. <script>
  10. $("option").each(function(){
  11. if($(this).val() == 11){
  12. return false; // false时相当于break, 如果return true 就相当于continue。
  13. }
  14. alert($(this).val());
  15. });
  16. </script>

jQuery中each的break和continue的更多相关文章

  1. Delphi中exit、break、continue等跳出操作的区别

    Delphi中表示跳出的有break,continue,abort,exit,halt,runerror等 1.break 强制退出最近的一层循环(注意:只能放在循环里:而且是只能跳出最近的一层循环) ...

  2. Java中goto和break、continue实现区别

    goto 关键字很早就在程序设计语言中出现.事实上,goto 是汇编语言的程序控制结构的始祖:“若条件 A,则跳到这里:否则跳到那里”.若阅读由几乎所有编译器生成的汇编代码,就会发现程序控制里包含了许 ...

  3. shell中跳出循环语句break和continue

    在使用while或for循环语句过程中,也许碰到某个特殊条件,我们需要跳过当次循环或整个循环,这是就需要借助break和continue. break表示跳出本层循环,break n表示跳出循环的层数 ...

  4. javascript中标签与break和continue的配合使用

    var num = 0; outermost: for (var i=0; i<10; i++) { for (var j=0; j<10; j++) { if (j==5 || i==5 ...

  5. C++中 return,break,continue的用法

    引用:https://blog.csdn.net/smf0504/article/details/51315835 https://blog.csdn.net/ting_junhui/article/ ...

  6. java中return、break、continue的区别

    1.return @Testpublic void testReturn(){ for (int j = 1; j < 3; j++) { for (int i = 1; i < 5; i ...

  7. 循环中的自变量-break和continue

    1.break 作用:break 用于终止循环的执行, 过程:当执行到break语句后,程序将跳出循环,执行循环语句后边的代码 i=1 while i<10: if i==5: break pr ...

  8. jquery each循环,实现break和continue的功能

    break----用return false; continue --用return ture;

  9. jquery中each中使用break和continue

    在jquery中each中直接使用break或者continue会提示:必须在循环中使用.会报错不能直接使用. 但是,是不是就不能用呢,答案是的,但是换种方法可以达到相同的效果: 可以只用return ...

随机推荐

  1. hdoj 5392 Infoplane in Tina Town

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5392 #include<stdio.h> #include<cstring> ...

  2. 将nginx配置为服务,php-fpm配置说明

    编写shell脚本 vi /etc/init.d/nginx #!/bin/bash # # Startup script for the PHP-FPM server. # # chkconfig: ...

  3. linux内核完全注释之微型计算机组成结构

    计算机组成原理 1.传统计算机计算机组成框图 CPU通过地址线.数据线.控制线组成的本地总线(或内部总线),与系统的其他部分进行数据通信,地址线用于提供内存或I/O设备的地址,指明所需读写数据的具体操 ...

  4. 固定分隔符字符串与数组互转及ArrayList与数组(Array)互转

    1.字符串转数组 这个相信多数人都会常用,string.split方法,分隔符可以为多个.详细信息参见MSDN string[] actionCfgs = _para.Split(new char[] ...

  5. js查看浏览器类型和版本

    var Sys = {}; var ua = navigator.userAgent.toLowerCase(); var s; var scan; (s = ua.match(/msie ([\d. ...

  6. Android ListView标题置顶效果实现

    一. 有图有真相     二.实现: 1. 基于ListView分类效果 2. TitleView即标题的处理(创建) 3. 处理TitleView的三种状态 三.源码: 例子下载 实现可以看代码,具 ...

  7. 仿Android网易新闻客户端,并增加水平图片滑动,改进阅读体验

    仿网易新闻Android端APP 主要功能展示和代码实现 差不多花了一周的时间,目前实现的了新闻下的包括头条.体育.娱乐的一系列的新闻展示,以及点击后进入的新闻详情展示. 目前效果 目前效果请访问该网 ...

  8. [CSS] Introduction to CSS Columns

    Learn how to use CSS columns to quickly lay out fluid columns that are responsive, degrade gracefull ...

  9. [Angular 2] Controlling Rx Subscriptions with Async Pipe and BehaviorSubjects

    Each time you use the Async Pipe, you create a new subscription to the stream in the template. This ...

  10. [Angular 2] Share a Service Across Angular 2 Components and Modules

    Services are used to share data between components. They follow a module pattern that allows you to ...