HTML DOM rowIndex 属性
定义和用法
rowIndex 属性返回某一行在表格的行集合中的位置(row index)。
语法
- tablerowObject.rowIndex
实例
下面的例子返回了某一行在表格中的位置:
- <html>
- <head>
- <script type="text/javascript">
- function alertRowIndex()
- {
- alert(document.getElementById("tr1").rowIndex);
- }
- </script>
- </head>
- <body>
- <table border="1">
- <tr id="tr1">
- <th>Firstname</th>
- <th>Lastname</th>
- </tr>
- <tr id="tr2">
- <td>Peter</td>
- <td>Griffin</td>
- </tr>
- </table>
- <br />
- <input type="button" onclick="alertRowIndex()"
- value="Alert row index" />
- </body>
- </html>