TableHeader cellIndexProperty

TableHeader 对象参考手册TableHeader Object

Examples

Click on different cells to pop up an alert box showing their index positions:

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

Try it Yourself »

Definition and Usage

The cellIndex property returns the position of a cell in the cell collection of a 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: A number, indicating the position of the cell in the cell collection of a table row.


More Examples

Example

Return the index position of each cell in a table row:

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 Yourself »


TableHeader 对象参考手册TableHeader Object

Other Extensions