Latest web development tutorials

HTML DOM Table deleteRow () method

Table Object Reference Table Object

Definition and Usage

deleteRow () method is used to delete the specified location from the table row

grammar

tableObject.deleteRow(index)

描述
index 指定删除指定行的数字索引 (以 0 开始).


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support deleteRow () method


Examples

Examples

Delete the first line of the table:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<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()">删除表格第一行</button>

</body>
</html>

try it"


Examples s

More examples

Click to delete the table row
In this example, click after use deleteRow () method to delete rows


Table Object Reference Table Object