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