Jquery each()循环遍历的使用

一: 

var arry=["a","b","c"];

 $.each(arry,function(i,val){

  alert(i);

  alert(val);

})

i输出的的1,2,3,

val输出的是a,b,c,

二:

var arry =[["a","aa","aaa"],["b","bb","bbb"],["c","cc","ccc"]];

$.each(arry,function(i,val){

  alert(i);

  alert(val);

})

i输出的是:0,2,3,

val输出的是:["a","aa","aaa"],["b","bb","bbb"],["c","cc","ccc"]

 

三:

var arry=[["a","aa","aaa"],["b","bb","bbb"],["c","cc","ccc"]];;

$.each(arry,function(i,item){

  $.each(item,function(k,vals){

    alert(i);

    alert(vals);

})

})

i输出的是:0,1,2,0,1,2,0,1,2,

vals:a,aa,aaa,b,bb,bbb,c,cc,ccc

 

你可能感兴趣的:(Jquery each()循环遍历的使用)