Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM TableHeader cellIndex property

TableHeader cellIndex property

TableHeader Object Reference The TableHeader object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 »


TableHeader Object Reference The TableHeader object