Latest web development tutorials

HTML DOM 그럴 deleteCell () 메소드

그럴 개체 참조 그럴 객체

정의 및 사용

deleteCell () 메소드는 테이블 셀 (<TD> 요소)에서 행을 삭제하는 데 사용됩니다.

문법

trObject.deleteCell(index)

描述
index

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

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



브라우저 지원

Internet ExplorerFirefoxOperaGoogle ChromeSafari

모든 주요 브라우저 deleteCell를 지원 () 메소드


다음은 행에서 셀을 삭제합니다 :

<!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>

»시도


그럴 개체 참조 그럴 객체