Latest web development tutorials

HTML DOM tr deleteCell () method

tr Object Reference tr objects

Definition and Usage

deleteCell () method is used to delete rows in a table cell (<td> element).

grammar

trObject.deleteCell(index)

描述
index

参数 index 是要删除的表元在行中的位置。

该方法将删除表行中指定位置的表元。



Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support deleteCell () method


Examples

Examples

The following example deletes a cell from the line:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.com)</title>
<script>
function displayResult(){
    var firstRow=document.getElementById("myTable").rows[0];
    firstRow.deleteCell(0);
}
</script>
</head>
<body>

<table id="myTable" border="1">
    <tr>
        <td>First cell</td>
        <td>Second cell</td>
        <td>Third cell</td>
    </tr>
</table>
<br>
<button type="button" onclick="displayResult()">删除第一个单元格</button>

</body>
</html>

try it"


tr Object Reference tr objects