HTML | DOM TableData cellIndex Property
The TableData cellIndex Property is used for returning the position of a cell in the cells collection of a table row.
Syntax:
- It return the cellIndex Property.
tabledataObject.cellIndex
Return Value: It returns a numeric value which represents the position of the cell in the cells collection of the table row
Example:
<!DOCTYPE html> < html > < head > < style > table, th, td { border: 1px solid green; } </ style > </ head > < body > < h1 > w3wiki </ h1 > < h2 >HTML DOM TableData cellIndex Property</ h2 > < p > Click on the row to get the cell index of the TableData </ p > < table > < tr > < td id = "GFG" onclick = "myBeginner(this)" >Beginner</ td > < td >Beginner</ td > < td id = "GFG" onclick = "myBeginner(this)" >For</ td > < td id = "GFG" onclick = "myBeginner(this)" >Beginner</ td > < td id = "GFG" onclick = "myBeginner(this)" >Beginner</ td > < td id = "GFG" onclick = "myBeginner(this)" >Beginner</ td > < td id = "GFG" onclick = "myBeginner(this)" >For</ td > < td id = "GFG" onclick = "myBeginner(this)" >Beginner</ td > < td id = "GFG" onclick = "myBeginner(this)" >Beginner</ td > < td id = "GFG" onclick = "myBeginner(this)" >Beginner</ td > < td id = "GFG" onclick = "myBeginner(this)" >For</ td > < td id = "GFG" onclick = "myBeginner(this)" >Beginner</ td > </ tr > </ table > < p id = "sudo" ></ p > < script > function myBeginner(x) { alert("cell index is: " + x.cellIndex); } </ script > </ script > </ body > </ html > |
Output:
Before Clicking On Table cell:
After Clicking On Table cell:
Supported Browsers: The browsers supported by DOM TableData cellIndex Property are listed below:
- Google Chrome
- Internet Explorer
- Firefox
- Apple Safari
- Opera