TableHeader headers Property

TableHeader Object Reference TableHeader Object

Example

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

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

The result of x will be:

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 containing header information for the current data cell.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The headers property is supported in all major browsers.


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 Reference TableHeader Object

SHARE THIS PAGE

COLOR PICKER

colorpicker





Search w3schools.com:

Translate w3schools.com: