HTML DOM deleteRow() 方法
定義和用法
deleteRow() 方法用于從表格刪除指定位置的行。
語(yǔ)法
tableObject.deleteRow(index)
說明
參數(shù) index 指定了要?jiǎng)h除的行在表中的位置。行的編碼順序就是他們?cè)谖臋n源代碼中出現(xiàn)的順序。<thead> 和 <tfoot> 中的行與表中其它行一起編碼。
實(shí)例
The following example deletes the first row of the table:
<html>
<head>
<script type="text/javascript">
function delRow()
{
document.getElementById('myTable').deleteRow(0)
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>Row1 cell1</td>
<td>Row1 cell2</td>
</tr>
<tr>
<td>Row2 cell1</td>
<td>Row2 cell2</td>
</tr>
</table>
<br />
<input type="button" onclick="delRow()"
value="Delete first row">
</body>
</html>