<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title></title>
<script src="https://code.jquery.com/jquery-3.2.1.min.js"></script>
</head>
<body>
<table id='tab' border="1">
<thead>
<tr style="background-color:#CCCCCC;">
<th>名称</th>
<th>数量</th>
<th>价格</th>
</tr>
</thead>
<tbody>
</tbody>
</table>
</body>
<script>
//水果数量
var fruit = {
'苹果': 0,
'香蕉': 2,
'水梨': 0,
'葡萄': 8,
'火龙果': 14,
}
var tianmao = [{
id: 1,
name: '橘子',
price: 8
},
{
id: 2,
name: '香蕉',
price: 8
},
{
id: 3,
name: '橘子',
price: 8
},
{
id: 4,
name: '水梨',
price: 8
},
{
id: 5,
name: '火龙果',
price: 8
},
{
id: 6,
name: '葡萄',
price: 8
}
]
tianmao.forEach(function(obj) {
/*for(var i in tianmao) {
for(var k in tianmao[i]) {
if(tianmao[i][k] == "undefined") {
//delete tianmao[i];
tianmao.splice(i, 1);
i = i - 1;
break;
}
}
}*/通过遍历数据得到table如图,现在想删除掉数量未定义和为0的行tr,但实际table是带有分页得,方法一遍历不到所有得行(只能一页)行不通,怎么在append前,处理json得到想要得结果。谢谢十分~
添加回答
举报
0/150
提交
取消