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
支持 支持 支持 支持 支持