Latest web development tutorials

HTML DOM Table deleteCaption() 方法

Table 對象參考手冊 Table對象

定義和用法

deleteCaption() 方法用於刪除表格的caption 元素及其內容。

提示:在表格中創建新的標題請使用createCaption()方法。

語法

tableObject.deleteCaption()


瀏覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要瀏覽器都支持deleteCaption() 方法


實例

實例

下面的例子刪除表格的標題:

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>本教程(w3big.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>
    <tr>
        <td>cell 3</td>
        <td>cell 4</td>
    </tr>
</table>
<br>
<button type="button" onclick="displayResult()">删除标题</button>

</body>
</html>

嘗試一下»


Table 對象參考手冊 Table對象