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:
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 >
GeeksForGeeks
</ 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 = "myGeeks(this)" >Geeks</ td >
< td >Geeks</ td >
< td id = "GFG" onclick = "myGeeks(this)" >For</ td >
< td id = "GFG" onclick = "myGeeks(this)" >Geeks</ td >
< td id = "GFG" onclick = "myGeeks(this)" >Geeks</ td >
< td id = "GFG" onclick = "myGeeks(this)" >Geeks</ td >
< td id = "GFG" onclick = "myGeeks(this)" >For</ td >
< td id = "GFG" onclick = "myGeeks(this)" >Geeks</ td >
< td id = "GFG" onclick = "myGeeks(this)" >Geeks</ td >
< td id = "GFG" onclick = "myGeeks(this)" >Geeks</ td >
< td id = "GFG" onclick = "myGeeks(this)" >For</ td >
< td id = "GFG" onclick = "myGeeks(this)" >Geeks</ td >
</ tr >
</ table >
< p id = "sudo" ></ p >
< script >
function myGeeks(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
Last Updated :
01 Nov, 2019
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...