[问]

I'm trying to iterate through an array of elements. jQuery's documentation says:

jquery.Each() documentation

Returning non-false is the same as a continue statement in a for loop, it will skip immediately to the next iteration.

I've tried calling 'return non-false;' and 'non-false;' (sans return) neither of which skip to the next iteration. Instead, they break the loop. What am i missing?

【答】

What they mean by non-false is:

return
true;

So this code:

var arr = [ "one", "two", "three", "four", "five" ];

$.each(arr, function(i) {

if(arr[i] == 'three') {

return
true;

}

alert(arr[i]);

});

Will alert one, two, four, five

 

From: https://stackoverflow.com/questions/481601/how-to-skip-to-next-iteration-in-jquery-each-util

How to skip to next iteration in jQuery.each() util?的更多相关文章

  1. jQuery实现表格冻结行和列

    前几天,遇到一个需求是要将表格的前几行和前几列冻结即固定,就是在有滚动条的情况下,保持那几行和那几列固定,这个需求其实是一个非常常见的需求,因为在涉及好多行和列时,在拖动滚动条时,我们需要知道每行每列 ...

  2. 理解 break, continue, return 和 exit

    你们知道 “break”, “continue”, “return” 和 “exit”的作用吗? 它们是功能强大的语言结构体.下面通过一个测试函数来说明它们之间的不同. 1 2 3 4 5 6 7 8 ...

  3. 4-14-17 JavaScript知识点总结(包括JOSN, ajax等,来源w3c)

    JavaScript 也称 ECMAScript as "JavaScript" It is designed to run as a scripting language in ...

  4. websocket业务代码

    需求 用户登陆后,服务器实时推送用户的订单提醒,用websocket处理. 方案 两个js,notify-socket.js处理socket的连接,和socket的处理. nofify.js,做右下角 ...

  5. seajs hello world

    http://localhost/seajs/index.html <!doctype html> <head> <title>Hello Seajs</ti ...

  6. RequireJS简单实用说明

    OM前端框架说明 om前端框架采用RequireJS,RequireJS  是一个JavaScript模块加载器.它非常适合在浏览器中使用, 它非常适合在浏览器中使用,但它也可以用在其他脚本环境, 就 ...

  7. UI5-文档-4.8-Translatable Texts

    在这一步中,我们将UI的文本移动到一个单独的资源文件中. 这样,他们都在一个中心位置,可以很容易地翻译成其他语言.这个国际化过程(简称i18n)是在SAPUI5中通过使用一种特殊的资源模型和标准的数据 ...

  8. grunt与requirejs结合使用

    // 多个js压缩成一个js // Project configuration. module.exports = function(grunt) { // 使用严格模式 'use strict'; ...

  9. Webpack抽离第三方类库以及common解决方案

    前端构建场景有两种,一种是单页面构建,另一种是多入口构建多页面应用程序(我视野比较小,目前就知道这两种),下面我们针对这两种场景总结了几种抽离第三方类库以及公共文件的解决方案. 如果有哪些地方优化不周 ...

随机推荐

  1. Anaconda、Miniconda、Conda、pip的相互关系_我是刘振岗_新浪博客

    Anaconda.Miniconda.Conda.pip的相互关系_我是刘振岗_新浪博客 http://blog.sina.com.cn/s/blog_8a122dcf0102x9vn.html

  2. AxonFramework

    AxonFramework

  3. maria-developers 开发者邮件

    https://lists.launchpad.net/maria-developers/

  4. delphi 结构体和TList的用法

    type  PRecord = ^TMyRec;  TMyRec = record    s: string[8];    i: integer;    d: double;end;var   MyL ...

  5. Time Zones And Daylight Savings Time

    This page describes code for working with Time Zones and Daylight Savings Time. Neither VBA nor VB6 ...

  6. 线程中sleep方法和wait方法有什么区别?(转)

    本文转自https://www.cnblogs.com/linkstar/p/6043846.html 线程中sleep方法和wait方法有什么区别?   如果你没有接触过java的多线程,那么多对于 ...

  7. CentOS 安装 nexus (maven 私服)

    原文:https://www.sunjianhua.cn/archives/centos-nexus.html 1.下载 wget http://download.sonatype.com/nexus ...

  8. 【elasticsearch】关于elasticSearch的基础概念了解【转载】

    转载原文:https://www.cnblogs.com/chenmc/p/9516100.html 该作者本系列文章,写的很详尽 ================================== ...

  9. 关于面试总结10-selenium中隐藏元素如何定位?(hidden、display: none)

    前言 面试题:selenium中隐藏元素如何定位?这个是很多面试官喜欢问的一个题,如果单纯的定位的话,隐藏元素和普通不隐藏元素定位没啥区别,用正常定位方法就行了 但是吧~~~很多面试官自己都搞不清楚啥 ...

  10. 关于 java,nio,bufferedreader,bytebuffer

    有没有一种方法来读取的ByteBuffer有一个BufferedReader,而无需将其转换为String优先?我想读通过一个相当大的 ByteBuffer作为文本行和我想避免它写入磁盘性能方面的原因 ...