TableHeader headers 属性

定义和用法

headers 属性设置或返回 headers 属性的值。

<th> headers 属性 规定包含当前数据单元的标题信息的标题单元列表。

另请参阅:

HTML Reference Manual:HTML <th> ɗanar

实例

例子 1

返回 id 为 "myTh" 的 <th> 元素的 headers 属性值:

var x = document.getElementById("myTh").headers;

亲自试一试

例子 2

显示第二行的单元格标题:

var table = document.getElementById("myTable");
var txt = "";
var i;
for (i = 0; i < table.rows[1].cells.length; i++) {
  txt = txt + table.rows[1].cells[i].headers + "<br>";
}

亲自试一试

例子 3

更改 id 为 "myTh" 的 <th> 元素的 headers 属性的值:

document.getElementById("myTh").headers = "newValue";

亲自试一试

语法

返回 headers 属性:

tableheaderObject.headers

设置 headers 属性:

tableheaderObject.headers = header_ids

Attribute Value

Value Description
header_ids Dauka daidai tsawon idan kudi da ke ɗaukar header cells tare da kudi na kaiwa.

Technical Details

Return Value: Anan ɗanar, kuma ya ɗauki kudi na gaba tare da idan kudi da ke tsamman.

Browser Support

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Support Support Support Support Support

Related Pages

HTML Reference Manual:HTML <th> ɗanar