TableHeader headersProperty

TableHeader 对象参考手册TableHeader Object

Example

Return the value of the headers attribute of the <th> element with id "myTh":

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

xThe output result is:

fname

Try it yourself »

Definition and Usage

The headers property sets or returns the value of the headers attribute.

The headers attribute specifies a list of header cells that contain header information for the current data cell.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support the headers attribute.


Syntax

Return the headers property:

tableheaderObject.headers

Set the headers property:

tableheaderObject.headers=header_ids

Property Values

Value Description
header_ids Specifies a space-separated list of one or more header cell IDs related to the table cell.

Technical Details

Return Value: A string containing a space-separated list of header cell identifiers.


More Examples

Example

Display the cell headers of the second row:

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;

Try it yourself »

Example

Change the value of the headers attribute of the <th> element with id "myTh":

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

Try it yourself »


Related Articles

HTML Reference Manual:HTML <th> headers Attribute


TableHeader 对象参考手册TableHeader Object

Other Extensions