$.each()与$(selector).each()区别
jQuery.each( collection, callback(indexInArray, valueOfElement) )可用于迭代任何集合,无论是“名/值”对象(JavaScript对象)或数组。
而$(selector).each()专门用来遍历一个jQuery对象
$.("li").each(function(index,elem){
});

$.each( ['a','b','c'], function(index,value){
//Index #0: a
//Index #1: b
//Index #2: c
console.log( "Index #" + index + ": " + value );
});

$.each( { name: "John", lang: "JS" }, function(index,value){
//Index #name: John
//Index #lang: JS
console.log( "Index #" + index + ": " + value );
});
随机推荐
- 关于Struts2配置文件名修改的问题
突发奇想的想知道Struts2的配置文件名是否可以修改,自己最早使用Struts2的时候,只是单纯的将配置文件命名为“struts.xml”,这是Strut2默认的配置文件名,我一直也没有去修改它的命 ...
- 关于windows系统里locale、code page、ANSI编码的问题
最近把公司代码库里的代码同步下来之后编译了下,竟然出问题.问下同事说代码库肯定没问题,而我啥也没改,那到底那里出问题了呢? VS2018报的错误是:error RC2001: newline in c ...
- Java-从堆栈常量池解析equals()与==
一.基本概念 ①JAVA中的基本数据类型(简单类型,内置类型): 字节型(byte),短整型(short),整型(int),长整型(long),字符型(char),浮点型(float),双精度型(do ...
- leetcode260
public class Solution { public int[] SingleNumber(int[] nums) { var dic = new Dictionary<int, int ...
- RHCE7 学习里程-3基本命令
一.centos7 基本命令 #创建文件 touch a.b #创建文件夹 mkdir abc #删除文件 rm -f a.b #删除空文件夹 rm -rf abc #重命名文件 mv 源文件 新文 ...
- 加密算法blowfish 多语言
php加密算法blowfish <?php /** * Created by PhpStorm. * User: Administrator * Date: 2016-02-14 * Time: ...
- linux系统构架 - LB集群之LVS介绍
LB 集群是 load balance 集群的简写,翻译成中文就是负载均衡集群.常用的负载均衡开源软件有 nginx.lvs.keepalived ,商业的硬件负载设备 F5.Netscale. LB ...
- ATL项目编译注册dll的时候报权限错误:error MSB8011: Failed to register output. Please try enabling Per-user Redirection or register the component from a command prompt with elevated permissions.
atl工程在vs2013编译的时候会在编译成功之后去使用 regsvr32 去注册 生成的 .dll 偶尔在编译的时候会遇到下面的错误: error MSB8011: Failed to regist ...
- easyui datagrid editor onBeforeEdit事件下使用getEditor和getEditors失效
我在使用onClickRow: function(rowIndex,rowData){ if(editRow!=-1){ ...
- VSS/RSS/PSS/USS
[VSS/RSS/PSS/USS] Android has a tool called procrank (/system/xbin/procrank), which lists out the me ...