JavaScript 参考手册教程
HTML DOM td/th cellIndex 属性
HTML DOM td/th cellIndex 属性
td/th cellIndex 属性
定义和用法
cellIndex 属性可返回一行的单元格集合中单元格的位置。
语法
返回 cellIndex 属性:
tdObject.cellIndex
或者
thObject.cellIndex
或者
thObject.cellIndex
提示: cellIndex 属性没有默认值。
浏览器支持
所有主流浏览器都支持 cellIndex 属性
实例
实例
弹出单元格的位置(cellIndex):
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>非常教程(verydoc.net)</title>
<script>
function displayResult(x){
alert("Cell index is: " + x.cellIndex);
}
</script>
</head>
<body>
<table border="1">
<tr>
<td onclick="displayResult(this)">单击显示单元格下标</td>
<td onclick="displayResult(this)">单击显示单元格下标</td>
</tr>
</table>
</body>
</html>
<html>
<head>
<meta charset="utf-8">
<title>非常教程(verydoc.net)</title>
<script>
function displayResult(x){
alert("Cell index is: " + x.cellIndex);
}
</script>
</head>
<body>
<table border="1">
<tr>
<td onclick="displayResult(this)">单击显示单元格下标</td>
<td onclick="displayResult(this)">单击显示单元格下标</td>
</tr>
</table>
</body>
</html>
尝试一下 »
HTML DOM td/th cellIndex 属性 |
---|
JavaScript 参考手册
JavaScript 参考手册提供了完整的 JavaScript 对象、浏览器对象、HTML DOM 对象手册。手册包含了每个对象、属性、方法的实例。