TableHeader cellIndex property

Definition and Usage

cellIndex property returns the cell index of the cell in the table row cells collection location.

See also:

HTML Reference Manual:HTML <th> etikett

Instance

Example 1

Click on different cells to prompt their index positions:

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

Prova själv

Example 2

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

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

Prova själv

Syntax

Returnera cellIndex-attribut:

tableheaderObject.cellIndex

Tekniska detaljer

Returvärde: Numerisk värde som anger cellens plats i cells samlingen för tabellraden.

Webbläsarstöd

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
Stöd Stöd Stöd Stöd Stöd