CSSStyleDeclaration: length-Eigenschaft
Baseline Widely available
This feature is well established and works across many devices and browser versions. It’s been available across browsers since September 2015.
Die schreibgeschützte Eigenschaft gibt eine ganze Zahl zurück, die die Anzahl der Stildeklarationen in diesem CSS-Deklarationsblock darstellt.
Wert
Eine ganze Zahl, die die Anzahl der Stile angibt, die explizit auf dem Elternteil der Instanz gesetzt sind.
Beispiele
Das Folgende ermittelt die Anzahl der explizit gesetzten Stile auf dem folgenden HTML-Element:
html
<div
id="div1"
style="margin: 0 10px; background-color: #CA1; font-family: monospace"></div>
JavaScript-Code:
js
const myDiv = document.getElementById("div1");
const divStyle = myDiv.style;
const len = divStyle.length; // 6
Spezifikationen
Specification |
---|
CSS Object Model (CSSOM) # dom-cssstyledeclaration-length |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
length |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
The compatibility table on this page is generated from structured data. If you'd like to contribute to the data, please check out https://github.com/mdn/browser-compat-data and send us a pull request.