TableHeader cellIndex property
Example
Click on different cells to pop up an alert box showing their index positions:
alert("Cell index is: " + x.cellIndex);
Try it »
Definition and Usage
The cellIndex property returns the position of the cell within the collection of cells in the table row.
Browser support





All major browsers support the cellIndex property.
Syntax
Return the cellIndex property:
tableheaderObject
.cellIndex
Technical Details
| Return Value: | Number, representing the position of the cell within the collection of cells in the table row. |
|---|
More examples
Example
Return the index position of each cell in the table row:
var x = document.getElementsByTagName("th");
var txt = "";
for (var i=0; i { txt = txt + "The index of Cell "+(i+1)+" is: "+x[i].cellIndex+"
} document.getElementById("demo").innerHTML=txt; Try it »
";
The TableHeader object