X
HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

TableData cellIndex Property

TableData Object Reference TableData Object

Example

Click on different cells to alert their index position:

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

Try it yourself »


Definition and Usage

The cellIndex property returns the position of a cell in the cells collection of a table row.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The cellIndex property is supported in all major browsers.


Syntax

Return the cellIndex property:

tabledataObject.cellIndex

Technical Details

Return Value: A Number, representing the position of the cell in the cells collection of the table row


More Examples

Example

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

var x = document.getElementsByTagName("td");
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 »


TableData Object Reference TableData Object

Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates FREE Website Templates Free HTML Templates

SHARE THIS PAGE

facebook