X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY ANGULAR BOOTSTRAP XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

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;
document.getElementById("demo").innerHTML = x;

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>";
}
document.getElementById("demo").innerHTML = txt;

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

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook