dw中怎么删除tr?
删除tr有两种方法
动态拼接tr的部分代码
$.each(data,function (i,n) {
str+="<tr id=\"tr_"+n.id+"\">";
str+="<td><input type=\"checkbox\" value=\""+n.id+"\"/></td>";
str+="<td>"+n.name+"</td>";
str+="<td>"+n.startDate+"</td>";
str+="<td>"+n.endDate+"</td>";
str+="<td>"+n.owner+"</td>";
str+="</tr>";
})
$("#tbody").html(str);
1
2
3
4
5
6
7
8
9
10
1
2
3
4
5
6
7
8
9
10
方法一
var checkboxs=$("#tbody input[type='checkbox']:checked");
$.each(checkboxs,function () {
$(this).parent().parent().remove();
})
1
2
3
4
5
1
2
3
4
5
方法二
在添加tr时,设置唯一的id
var checkboxs=$("#tbody input[type='checkbox']:checked");
$.each(checkboxs,function () {
$("#tr_"+this.value).remove();
})
Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有 粤ICP备16019765号
广州京杭网络科技有限公司 版权所有