td/th cellIndexProperty
td/th Object
Definition and Usage
The cellIndex property returns the position of a cell in the row's cell collection.
Syntax
Return the cellIndex property:
tdObject.cellIndex
Or
thObject.cellIndex
Or
thObject.cellIndex
Tip:The cellIndex property has no default value.
Browser Support
![]()
![]()
![]()
![]()
![]()
All major browsers support the cellIndex property.
Example
Example
Pop up the position of the cell (cellIndex):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function displayResult(x){
alert("Cell index is: " + x.cellIndex);
}
</script>
</head>
<body>
<table border="1">
<tr>
<td onclick="displayResult(this)">Click to display cell index</td>
<td onclick="displayResult(this)">Click to display cell index</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>Rookie Tutorial (example.com)</title>
<script>
function displayResult(x){
alert("Cell index is: " + x.cellIndex);
}
</script>
</head>
<body>
<table border="1">
<tr>
<td onclick="displayResult(this)">Click to display cell index</td>
<td onclick="displayResult(this)">Click to display cell index</td>
</tr>
</table>
</body>
</html>
Try it Yourself »
td/th Object Other Extensions