Table createCaption() 方法
示例
為表格建立一個帶有文字的 <caption> 元素
var table = document.getElementById("myTable").createCaption();
table.innerHTML = "<b>My table caption</b>";
自己動手試一試 »
描述
createCaption() 方法建立一個空的 <caption> 元素並將其新增到表格中。
注意:如果表格中已存在 <caption> 元素,則 createCaption() 方法將返回現有的元素,而不會建立新的元素。
提示: 要從表格中移除 <caption> 元素,請使用 deleteCaption() 方法。
瀏覽器支援
方法 | |||||
---|---|---|---|---|---|
createCaption() | 是 | 是 | 是 | 是 | 是 |
語法
tableObject.createCaption()
引數
無 |
技術詳情
返回值 | 新建立的(或已有的)<caption> 元素 |
---|
更多示例
示例
建立和刪除 <caption> 元素
function myCreateFunction() {
var table = document.getElementById("myTable").createCaption();
table.innerHTML = "<b>My table caption</b>";
}
function myDeleteFunction() {
document.getElementById("myTable").deleteCaption();
}
自己動手試一試 »
相關頁面
HTML 參考: HTML <caption> 標籤
↜ Table 物件