HTMLTableElement: deleteCaption() 方法
HTMLTableElement.deleteCaption() 方法用於從給定的 <table> 元素中移除 <caption> 元素。如果表格沒有關聯的 <caption> 元素,此方法將不執行任何操作。
語法
js
deleteCaption()
引數
無。
返回值
無(undefined)。
示例
此示例使用 JavaScript 刪除表格的標題。
HTML
html
<table>
<caption>
This caption will be deleted!
</caption>
<tr>
<td>Cell 1.1</td>
<td>Cell 1.2</td>
</tr>
<tr>
<td>Cell 2.1</td>
<td>Cell 2.2</td>
</tr>
</table>
JavaScript
js
let table = document.querySelector("table");
table.deleteCaption();
結果
規範
| 規範 |
|---|
| HTML # dom-table-deletecaption-dev |
瀏覽器相容性
載入中…