代码编辑器:
x
1
<script>
2
function deleteRow(r){
3
var i=r.parentNode.parentNode.rowIndex;
4
document.getElementById('myTable').deleteRow(i);
5
}
6
</script>
7
<table id="myTable" border="1">
8
<tr>
9
<td>Row 1</td>
10
<td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
11
</tr>
12
<tr>
13
<td>Row 2</td>
14
<td><input type="button" value="Delete" onclick="deleteRow(this)"></td>
15
</tr>
16
<tr>
17
<td>Row 3</td>
18
<td><input type="button" value="Delete" onclick="deleteRow(this)"></td>