THE WORLD'S LARGEST WEB DEVELOPER SITE
HTMLCSSJAVASCRIPTSQLPHPBOOTSTRAPJQUERYANGULARXML
 

TableData headers Property

TableData Object Reference TableData Object

Example

Return the value of the headers attribute of a <td> element with id "myTd":

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

The result of x will be:

name
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:

tabledataObject.headers

Set the headers property:

tabledataObject.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 <td> element with id "myTd":

document.getElementById("myTd").headers = "newValue";
Try it yourself »

Related Pages

HTML reference: HTML <td> headers attribute


TableData Object Reference TableData Object