<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="jquery-2.1.4.min.js" type="text/javascript" charset="utf-8"></script>
</head>
<body>
<div id="div1"></div>
</body>
<script type="text/javascript">
var array = [
{"name":'dong',"age":12},
{"name":'Tao',"age":12},
{"name":'Stady',"age":12}
];
var salesName='';
$.each(array, function(index, obj) {
salesName += obj.name +((array.length-1 > index)? ',':'');
});
console.log(salesName);
var naneValue = [];
for(var i = 0; i < array.length; i++) {
naneValue.push('<span> </span>' + array[i].name);
}
console.log(naneValue);
$('#div1').html(naneValue)
</script>
</html>
$.each,对象显示姓名加,,,
最新推荐文章于 2020-10-15 15:59:22 发布