Table deleteRow() 方法
定义和用法
deleteRow() 方法用于从表格删除指定位置的行
语法
tableObject.deleteRow(index)
值
|
描述
|
index
|
指定删除指定行的数字索引 (以 0 开始).
|
浏览器支持




所有主要浏览器都支持 deleteRow() 方法
实例
删除表格的第一行:
<html>
<head>
<script>
function displayResult()
{
document.getElementById("myTable").deleteRow(0);
}
</script>
</head>
<body>
<table id="myTable" border="1">
<tr>
<td>cell 1</td>
<td>cell 2</td>
</tr>
<tr>
<td>cell 3</td>
<td>cell 4</td>
</tr>
</table>
<br>
<button type="button" onclick="displayResult()">Delete first row</button>
</body>
</html>
更多实例
该实例在点击后使用 deleteRow() 方法删除行