jquery数组遍历
文章描述:
js数组遍历渲染效果
<div class="js-arr">
<span>jquery数组:</span>
<ul class="jquery_arr">
</ul>
</div>
var arr = [ "xml", "html", "css", "js" ];
var html="";
$.each(arr,function(key,val){
html+='<li>'+
'<span class="">'+key+' '+val+'</span>'+
'</li>'
});
$(".jquery_arr").append(html);
<div class="js-arr-list">
<span>jquery二维数组对象:</span>
<ul class="jquery_arr_list">
</ul>
</div>
var arrList = [
[{id:'1'},{name:'xml'},{desc:'xml简介'}],
[{id:'2'},{name:'html'},{desc:'html简介'}],
];
console.log(arrList);
var html="";
$.each(arrList,function(key,val){
html+='<li>'+
'<span class="">'+key+' '+val[1].name+' '+val[2].desc+'</span>'+
'</li>'
});
$(".jquery_arr_list").append(html);
var bool = $.isArray(arrList) //判断是否为数组 返回Boolean
console.log(bool) //true
发布时间:2022/10/13
发表评论