1. Web
  2. Web-APIs
  3. HTMLTableRowElement
  4. sectionRowIndex

Dieser Inhalt wurde automatisch aus dem Englischen übersetzt, und kann Fehler enthalten. Erfahre mehr über dieses Experiment.

View in English Always switch to English

HTMLTableRowElement: sectionRowIndex-Eigenschaft

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨Juli 2015⁩.

Die sectionRowIndex schreibgeschützte Eigenschaft des HTMLTableRowElement Interfaces repräsentiert die Position einer Zeile innerhalb des aktuellen Abschnitts (<thead>, <tbody> oder <tfoot>).

Wert

Der Index der Zeile oder -1, wenn die Zeile nicht Teil des Abschnitts ist.

Beispiele

Dieses Beispiel verwendet JavaScript, um alle Zeilennummern des tbody zu kennzeichnen.

HTML

html
<table>
 <thead>
 <tr>
 <th>Item</th>
 <th>Price</th>
 </tr>
 </thead>
 <tbody>
 <tr>
 <td>Bananas</td>
 <td>2ドル</td>
 </tr>
 <tr>
 <td>Oranges</td>
 <td>8ドル</td>
 </tr>
 <tr>
 <td>Top Sirloin</td>
 <td>20ドル</td>
 </tr>
 </tbody>
 <tfoot>
 <tr>
 <td>Total</td>
 <td>30ドル</td>
 </tr>
 </tfoot>
</table>

JavaScript

js
const rows = document.querySelectorAll("tbody tr");
rows.forEach((row) => {
 const z = document.createElement("td");
 z.textContent = `(row #${row.sectionRowIndex})`;
 row.appendChild(z);
});

Ergebnis

Spezifikationen

Specification
HTML
# dom-tr-sectionrowindex

Browser-Kompatibilität

Siehe auch

Help improve MDN

Learn how to contribute Diese Seite wurde automatisch aus dem Englischen übersetzt.

AltStyle によって変換されたページ (->オリジナル) /