$.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 );
});
随机推荐
- Vim编辑器基本操作学习(一)
最近在服务端编辑文件总不可避免要使用vim编辑器,下面就对学习到的常用命令进行总结,以便自己以后查看. 基本编辑命令 删除字符:x 删除一行:dd 删除换行符:J,同时将两行合并成一行 撤 ...
- 029:高可用之MHA
高可用之MHA 一.MHA 简介 MHA(Master High Availability)是一套优秀的作为MySQL高可用性环境下故障切换和主从提升的高可用软件.在MySQL故障切换过程中,MHA能 ...
- 【UVa】1601 The Morning after Halloween(双向bfs)
题目 题目 分析 双向bfs,对着书打的,我还调了好久. 代码 #include<cstdio> #include<cstring> #include<c ...
- 【UVA】1589 Xiangqi(挖坑待填)
题目 题目 分析 无力了,noip考完心力憔悴,想随便切道题却码了250line,而且还是错的,知道自己哪里错了,但特殊情况判起来太烦了,唯一选择是重构,我却没有这勇气. 有空再写吧,最近真的 ...
- 数据结构和算法之单向链表二:获取倒数第K个节点
我们在做算法的时候或多或少都会遇到这样的问题,那就是我们需要获取某一个数据集的倒数或者正数第几个数据.那么今天我们来看一下这个问题,怎么去获取倒数第K个节点.我们拿到这个问题的时候自然而然会想到我们让 ...
- django之分页器
view from django.shortcuts import render,HttpResponse # Create your views here. from app01.models im ...
- [POJ] Bode Plot
Description Consider the AC circuit below. We will assume that the circuit is in steady-state. Thus, ...
- dubbo 梗概及使用示例
阿里巴巴dubbo主页:http://code.alibabatech.com/wiki/display/dubbo/Home-zh 1. Dubbo是什么? Dubbo是一个分布式服务框架,致力于提 ...
- python开发_python中的list操作
对python中list的操作,大家可以参考: Python list 操作 以下是我个人的笔记: ============================================ Add b ...
- Python 小知识点(8)-- __new__
第一段代码如下: class Foo(object): def __init__(self,name): self.name = name print("Foo __init__" ...