`
icheng
  • 浏览: 831384 次
  • 性别: Icon_minigender_1
  • 来自: 珠海
文章分类
社区版块
存档分类
最新评论

HTML DOM rowIndex 属性

 
阅读更多

HTML DOM rowIndex 属性

定义和用法

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

语法

tablerowObject.rowIndex

实例

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

<html>
<head>
<script type="text/javascript">
function alertRowIndex()
{
alert(document.getElementById("tr2").rowIndex);
}
function CurrenRowIndex()
{
var currRowIndex=event.srcElement.parentNode.parentNode.rowIndex;
<!--alert(document.getElementById("mytable").rowIndex);-->
alert(currRowIndex);

}

</script>
</head>
<body>

<table border="1" id="mytable">
<tr id="tr1">
<th>Firstname</th>
<th>Lastname</th>
<th>״̬</th>
</tr>
<tr id="tr2">
<td>Peter</td>
<td>Griffin</td>
<td>
<input type="button" onclick="CurrenRowIndex()"
value="currentrow index" />
</td>
<tr id="tr3">
<td>Peter</td>
<td>Griffin</td>
<td>
<input type="button" onclick="CurrenRowIndex()"
value="currentrow index" />
</td>

</table>
<br />
<input type="button" onclick="alertRowIndex()"
value="Alert row index" />

</body>
</html>

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics