HTML DOM TableHeader headers attribute
Examples
Returns the id attribute value headers as "myTh" of <th> element:
var x = document.getElementById("myTh").headers;
document.getElementById("demo").innerHTML=x;
document.getElementById("demo").innerHTML=x;
x The output is:
fname
try it"
Definition and Usage
headers headers property sets or returns the value of the property.
headers attribute specifies a current data cell of the table header cell list header information.
Browser Support
All major browsers support headers attribute.
grammar
Returns headers attributes:
tableheaderObject .headers
Setting headers properties:
tableheaderObject .headers=header_ids
Property Value
值 | 描述 |
---|---|
header_ids | 规定一个空格分隔的一个或多个与表格单元格相关的表头单元格的 id 列表。 |
technical details
return value: | String that contains a space-separated list of header cell identifiers. |
---|
More examples
Examples
The second line of the cell header:
var table = document.getElementById("myTable");
var txt = "";
for (var i=0; i<table.rows[1].cells.length; i++)
{
txt = txt + table.rows[1].cells[i].headers + "<br>";
}
document.getElementById("demo").innerHTML=txt;
var txt = "";
for (var i=0; i<table.rows[1].cells.length; i++)
{
txt = txt + table.rows[1].cells[i].headers + "<br>";
}
document.getElementById("demo").innerHTML=txt;
try it"
Examples
Change the id attribute for the headers "myTh" of <th> element values:
document.getElementById("myTh").headers="newValue";
try it"
related articles
HTML Reference Manual: HTML <TH> headers attribute