TableRow sectionRowIndex 属性

定义和用法

sectionRowIndex 属性返回行在 <tbody>、<thead> 或 <tfoot> 的 rows 集合 中的位置。

另请参阅:

HTML 参考手册:HTML <tr> 标签

实例

例子 1

点击不同的行,输出它们的位置:

alert("Section row index is: " + x.sectionRowIndex);

亲自试一试

例子 2

返回 thead、tbody 和 tfoot 的 rows 集合中行的位置:

var x = document.getElementsByTagName("tr");
var txt = "";
var i;
for (i = 0; i < x.length; i++) {
  txt = txt + "The index of Row "+(i+1)+" is: "+x[i].sectionRowIndex+"<br>";
}

亲自试一试

语法

返回 sectionRowIndex 属性:

tablerowObject.sectionRowIndex

技术细节

返回值: 数值,表示行在 tbody、thead 或 tfoot 的 rows 集合 中的位置。

浏览器支持

Chrome Edge Firefox Safari Opera
Chrome Edge Firefox Safari Opera
支持 支持 支持 支持 支持


http://www.vxiaotou.com