A RetroSearch Logo

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

Search Query:

Showing content from https://developer.mozilla.org/de/docs/Web/API/HTMLCollection/length below:

HTMLCollection: length-Eigenschaft - Web-APIs | MDN

HTMLCollection: length-Eigenschaft

Baseline Widely available

Die HTMLCollection.length-Eigenschaft gibt die Anzahl der Elemente in einer HTMLCollection zurück.

Wert

Ein ganzzahliger Wert, der die Anzahl der Elemente in einer HTMLCollection darstellt.

Beispiele

Die length-Eigenschaft ist oft nützlich in der DOM-Programmierung. Sie wird oft verwendet, um die Länge einer Liste zu testen, um zu prüfen, ob sie überhaupt existiert. Sie wird auch häufig als Iterator in einer for-Schleife verwendet, wie in diesem Beispiel.

// All the elements with the class ".test" in the document
const items = document.getElementsByClassName("test");

// For each test item in the list,
// append the entire element as a string of HTML
let gross = "";
for (let i = 0; i < items.length; i++) {
  gross += items[i].innerHTML;
}

// gross is now all the HTML for the test elements
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