Table deleteCaption() 方法

Table 對象參考手冊 Table 對象

定義和用法

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

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

語法

tableObject.deleteCaption()


流覽器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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


實例

實例

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

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>IT研修(xuhuhu.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 對象