jQuery中$.each的用法

代码
1 var arr1 = [ "a", "b", "c", "d", "e" ];
2 $.each(arr1, function(){
3 alert(this);
4 });
5 输出:a b c d e
6  var arr2 = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]
7 $.each(arr2, function(i, item){
8 alert(item[0]);
9 });
10 输出:1 4 7
11  var obj = { one:1, two:2, three:3, four:4, five:5 };
12 $.each(obj, function(key, val) {
13 alert(obj[key]);
14 });
15 输出:1 2 3 4 5
posted @ 2010-03-21 18:17  Raycloud  阅读(467)  评论(0编辑  收藏  举报