Js代码
1 var arr1 = [ "one", "two", "three", "four", "five" ];
2 $.each(arr1, function(){
3 alert(this);
4 });
5 输出:one two three four five
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
Js代码
1. //json格式
2. var param = [{'subJobClass':'com.sample.quartz.MyJob','subJobMethod':'hello','taskParam':[{'username':'张三'},{'age':'28'},{'tel':'15818821129'}]}];
3.
4. //设置参数值
5. if(param.length>0){
6.
7.
8. alert(param[0].subJobClass);
9. alert(param[0].subJobMethod);
10.
11. var taskParam = param[0].taskParam ;
12.
13. //遍历任务参数数组
14. jQuery.each(taskParam,function(i, item){
15.
16. //解析单个任务参数
17. jQuery.each(item ,function(key){
18. alert(key);//key
19. alert(item[key]);//value
20.
21. });
22.
23. });
24. }