TableData cellIndex attribute
Definition and Usage
cellIndex
The attribute returns the position of the cell in the cell collection of the table row.
See also:
HTML Reference Manual:HTML <td> Tag
Instance
Example 1
Click on different cells to prompt their index positions:
alert("Cell index is: " + x.cellIndex);
Example 2
Return the index position of each cell in the table row:
var x = document.getElementsByTagName("td"); var txt = ""; var i; for (i = 0; i < x.length; i++) { txt = txt + "cell " + (i + 1) + " index is: " + x[i].cellIndex + "<br>"; }
Syntax
Returns the cellIndex property:
tabledataObject.cellIndex
Technical Details
Return Value: | A number representing the position of the cell within the cell collection of the table row. |
---|
Browser Support
Chrome | Edge | Firefox | Safari | Opera |
---|---|---|---|---|
Chrome | Edge | Firefox | Safari | Opera |
Support | Support | Support | Support | Support |