HTML DOM Caption 對象

Caption 對象

Caption 對象代表 HTML <caption> 元素。

訪問 Caption 對象

您可使用 getElementById() 來訪問 <caption> 元素:

var x = document.getElementById("myCaption");

親自試一試

創建 Caption 對象

您可使用 document.createElement() 方法來創建 <caption> 元素:

var x = document.createElement("CAPTION");

親自試一試

提示:您還可以使用 Table 對象的 createCaption 方法創建 <caption> 元素。

Caption 對象屬性

屬性 描述
align

HTML5 不支持。請改用 style.textAlignstyle.captionSide

設置或返回標題的對齊方式。

標準屬性和事件

Caption 對象支持標準屬性事件

相關頁面

HTML 教程:HTML 表格

HTML 參考手冊:HTML <caption> 標簽

JavaScript 參考手冊:HTML DOM Table 對象