Posted in Javascript onMarch 22, 2010
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
更详细的资料可以参考:
jQuery each()方法的使用方法
jQuery each()小议
jQuery $.each的用法说明
声明:登载此文出于传递更多信息之目的,并不意味着赞同其观点或证实其描述。
Reply on: @reply_date@
@reply_contents@