Latest web development tutorials

HTML DOM TableHeader cellIndex property

TableHeader Object Reference TableHeader objects

Examples

On different cell click, pop-up boxes to display them in index position:

alert("Cell index is: " + x.cellIndex);

try it"

Definition and Usage

cellIndex property returns the position of the cell in a cell in the table row set.


Browser Support

Internet ExplorerFirefoxOperaGoogle ChromeSafari

All major browsers support cellIndex property.


grammar

Back cellIndex properties:

tableheaderObject .cellIndex

technical details

return value: Number that represents the position of the cell in a cell in the table row set.


More examples

Examples

Returns the index position of each row of a table cell:

var x = document.getElementsByTagName("th");
var txt = "";
for (var i=0; i<x.length; i++)
{
txt = txt + "The index of Cell "+(i+1)+" is: "+x[i].cellIndex+"<br>";
}
document.getElementById("demo").innerHTML=txt;

try it"


TableHeader Object Reference TableHeader objects