<html>
<head>
<script>
function delte() {
var checkboxs = document.getElementsByName("c1");
var table = document.getElementById("mytable");
var allTrlength = table.rows.length;
var trIndex ;
for(var i=0; i<checkboxs.length; i++) {
for(var j=allTrlength - 1; j>0 ;j--) {
if(checkboxs[i].checked == true) {
table.deleteRow(checkboxs[i].parentNode.parentNode.rowIndex);
}
}
}
}
</script>
</head>
<body>
<table id="mytable">
<tr><td><input type="checkbox" name="c1"></td>
</tr>
<tr><td><input type="checkbox" name="c1"></td>
</tr>
<tr><td><input type="checkbox" name="c1"></td>
</tr>
<tr><td><input type="checkbox" name="c1"></td>
</tr>
<tr><td><input type="checkbox" name="c1"></td>
</tr>
<tr><td><input type="checkbox" name="c1"></td>
</tr>
</table>
<input type="button" value="delete" οnclick="delte();">
</body>
</html>
通过checkboxs动态删除多行tr
最新推荐文章于 2023-02-25 11:27:54 发布