jquery怎么遍历数组


当前第2页 返回上一页

3、each遍历一维数组

1

2

3

4

5

var arr=new Array();

arr=["aaa","bbb","ccc"];

$.each(arr,function(index,value){

     alert(i+"..."+value);

});

4、each遍历二维数组

1

2

3

4

5

6

7

8

9

10

$(function () {

    $.each([["aaa", "bbb", "ccc"], ["ddd", "eee", "fff"], ["ggg", "hhh", "iii"]], function (index, item) {

         alert(index + "..." + item);

         //输出0...aaa,bbb,ccc  1...ddd,eee,fff  2...ggg,hhh,iii   这时的index为数组下标,item相当于取这二维数组中的每一个数组

         $.each(item, function (index, itemobj) {

              alert(index + "....." + itemobj);

         });

    });

     //输出0...aaa,bbb,ccc  0...aaa 1...bbb 2...cccc  1...ddd,eee,fff  0...ddd 1...eee 2...fff  2...ggg,hhh,iii 0...ggg 1...hhh 2...iii

 });

相关推荐:js教程

以上就是jquery怎么遍历数组的详细内容,更多文章请关注木庄网络博客

返回前面的内容

相关阅读 >>

jQuery设置disabled属性与移除disabled属性

jQuery如何选择第几个元素

怎样在vue中使用jQuery

jQuery append()方法怎么用

如何判断jQuery class是否存在

如何解决jQuery ajax不兼容ie8的问题

jQuery中text()、val()和html()的区别是什么

js数组怎么删除某一项

如何解决jQuery不兼容问题

jQuery怎么让checkbox不选中?

更多相关阅读请进入《jQuery》频道 >>




打赏

取消

感谢您的支持,我会继续努力的!

扫码支持
扫码打赏,您说多少就多少

打开支付宝扫一扫,即可进行扫码打赏哦

分享从这里开始,精彩与您同在

评论

管理员已关闭评论功能...