HTMLTableRowElement: sectionRowIndex property
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since July 2015.
The The index of the row, or This example uses JavaScript to label all the row numbers of the sectionRowIndex
read-only property of the HTMLTableRowElement
interface
represents the position of a row within the current section (,
, or
).
Value
-1
if the row is not part of the section.Examples
tbody
.HTML
Item
Price
Bananas
$2
Oranges
$8
Top Sirloin
$20
Total
$30
JavaScript
const rows = document.querySelectorAll("tbody tr");
rows.forEach((row) => {
const z = document.createElement("td");
z.textContent = `(row #${row.sectionRowIndex})`;
row.appendChild(z);
});
Result
Specifications
Specification HTML
# dom-tr-sectionrowindexBrowser compatibility
See also