HTML DOM TableHeader headers Property
THE WORLD'S LARGEST WEB DEVELOPER SITE

TableHeader headers Property

❮ TableHeader Object

Example

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

var x = document.getElementById("myTh").headers;
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 containing header information for the current data cell.


Browser Support

Property
headers Yes Yes Yes Yes Yes

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 id's to one or more header cells the table cell is related to


Technical Details

Return Value: A String, containing a space-separated list of header cell identifiers

More Examples

Example

Display cell headers of second row:

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>";
}
Try it Yourself »

Example

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

document.getElementById("myTh").headers = "newValue";
Try it Yourself »

Related Pages

HTML reference: HTML <th> headers attribute


❮ TableHeader Object