tr rowIndex 属性

tr 对象参考手册 tr 对象

定义和用法

rowIndex 属性返回某一行(rows )在表格的行集合中的位置(row index)。

语法

返回 rowIndex 属性:

trObject.rowIndex

提示:rowIndex 属性没有默认值。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主流浏览器都支持 rowIndex 属性


实例

实例

下面的例子返回了某一行在表格中的位置:

<html>
<head>
<script>
function displayResult(x)
{
alert("Row index is: " + x.rowIndex);
}
</script>
</head>
<body>

<table border="1">
  <tr onclick="displayResult(this)">
    <td>Click to show rowIndex</td>
  </tr>
  <tr onclick="displayResult(this)">
    <td>Click to show rowIndex</td>
  </tr>
  <tr onclick="displayResult(this)">
    <td>Click to show rowIndex</td>
  </tr>
</table>

</body>
</html>

尝试一下 »


tr 对象参考手册 tr 对象