The StyleSheetList
interface represents a list of StyleSheet
.
It is an array-like object but can't be iterated over using Array
methods. However It can be iterated over in a standard for
loop over its indices, or converted to an Array
.
for (var i=0; i < document.styleSheets.length; i++){ var styleSheet = document.styleSheets[i]; }
var allCSS = [].slice.call(document.styleSheets) .reduce(function (prev, styleSheet) { if (styleSheet.cssRules) { return prev + [].slice.call(styleSheet.cssRules) .reduce(function (prev, cssRule) { return prev + cssRule.cssText; }, ''); } else { return prev; } }, '');
Specification | Status | Comment |
---|---|---|
CSS Object Model (CSSOM) The definition of 'CSSStyleSheetList' in that specification. | Working Draft |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | 1 | ? | 31 | ? | Yes | ? |
item |
1 | ? | 31 | ? | Yes | ? |
length |
1 | ? | 31 | ? | Yes | ? |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | ? | 31 | Yes | ? | ? |
item |
Yes | Yes | ? | 31 | Yes | ? | ? |
length |
Yes | Yes | ? | 31 | Yes | ? | ? |
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/StyleSheetList