A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://developer.cdn.mozilla.net/de/docs/Web/API/HTMLTableCellElement/cellIndex below:

HTMLTableCellElement: cellIndex-Eigenschaft - Web-APIs | MDN

HTMLTableCellElement: cellIndex-Eigenschaft

Baseline Widely available

Die cellIndex schreibgeschützte Eigenschaft des HTMLTableCellElement Schnittstelle repräsentiert die Position einer Zelle innerhalb ihrer Zeile (<tr>). Die erste Zelle hat einen Index von 0.

Wert

Gibt den Index der Zelle zurück oder -1, wenn die Zelle nicht Teil einer Zeile ist.

Beispiele

Dieses Beispiel fügt allen Zellnummern der ersten Zeile des tbody ein Label hinzu.

HTML
<table>
  <thead>
    <tr>
      <th>Item</th>
      <th>Price</th>
    </tr>
  </thead>
  <tbody>
    <tr>
      <td>Bananas</td>
      <td>$2</td>
    </tr>
    <tr>
      <td>Rice</td>
      <td>$2.5</td>
    </tr>
  </tbody>
</table>
table {
  border-collapse: collapse;
}

th,
td,
table {
  border: 1px solid black;
}

button {
  margin: 1em 1em 1em 0;
}
JavaScript
const rows = document.querySelectorAll("tbody tr");
const cells = rows[0].cells;

for (const cell of cells) {
  cell.textContent = `${cell.textContent} (cell #${cell.cellIndex})`;
}
Ergebnis Spezifikationen Browser-Kompatibilität MDN-Feedback-Box War diese Übersetzung hilfreich?

Diese Seite wurde automatisch aus dem Englischen übersetzt.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4