CSSStyleRule: styleMap-Eigenschaft
Limited availability
This feature is not Baseline because it does not work in some of the most widely-used browsers.
Die schreibgeschützte Eigenschaft styleMap
der CSSStyleRule
-Schnittstelle gibt ein StylePropertyMap
-Objekt zurück, das Zugriff auf die Eigenschaft-Wert-Paare der Regel bietet.
Wert
Ein StylePropertyMap
-Objekt.
Beispiel
Das folgende Beispiel zeigt, wie styleMap
verwendet wird, um einen Stil mit der StylePropertyMap.set()
-Methode zu ändern.
js
const stylesheet = document.styleSheets[0];
Object.values(stylesheet.cssRules).forEach((block) => {
if (block.selectorText === "button") {
block.styleMap.set("--mainColor", "black");
}
});
Spezifikationen
Specification |
---|
CSS Typed OM Level 1 # dom-cssstylerule-stylemap |
Browser-Kompatibilität
Report problems with this compatibility data on GitHubdesktop | mobile | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
styleMap |
Legend
Tip: you can click/tap on a cell for more information.
- Full support
- Full support
- No support
- No support
- See implementation notes.
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.