天天看點

Table deleteCaption() 方法

Table 對象

定義和用法

deleteCaption() 方法用于删除表格的 caption 元素及其内容。

提示:

在表格中建立新的标題請使用

createCaption() 方法。

文法

tableObject.deleteCaption()

浏覽器支援

Table deleteCaption() 方法
Table deleteCaption() 方法
Table deleteCaption() 方法
Table deleteCaption() 方法
Table deleteCaption() 方法

所有主要浏覽器都支援 deleteCaption() 方法

執行個體

下面的例子删除表格的标題:

<!DOCTYPE html>

<html>

<head>

<meta charset="utf-8">

<title>菜鳥教程(runoob.com)</title>

<script>

function displayResult(){

    document.getElementById("myTable").deleteCaption();

}

</script>

</head>

<body>

<table id="myTable" border="1">

<caption>這是個表格标題</caption>

    <tr>

        <td>cell 1</td>

        <td>cell 2</td>

    </tr>

        <td>cell 3</td>

        <td>cell 4</td>

    </tr>

</table>

<br>

<button type="button" onclick="displayResult()">删除标題</button>

</body>

</html>

Table 對象