---
title: "jQuery $.each的用法说明"
author: "mywebcode"
date: "2013-11-21T22:53:00Z"
tags: []
slug: "jquery-each"
draft: false
lastmod: "2014-04-30T09:16:47Z"
id: 2058358
url: "https://mywebcode.iteye.com/blog/2058358"
---

看例子：

代码如下:

var arr1 = \[ "a", "b", "c", "d", "e" ];  
$.each(arr1, function(){  
alert(this);  
});

输出：a b c d e  
复制代码 代码如下:  
var arr2 = \[\[1, 2, 3], \[4, 5, 6], \[7, 8, 9]]  
$.each(arr2, function(i, item){  
alert(item\[0]);  
});

输出：1 4 7  
复制代码 代码如下:  
var obj = { one:1, two:2, three:3, four:4, five:5 };  
$.each(obj, function(key, val) {  
alert(obj\[key]);  
});

输出：1 2 3 4 5