Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Unsere Freiwilligen haben diesen Artikel noch nicht in Deutsch übersetzt. Machen Sie mit und helfen Sie, das zu erledigen!

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.

Examples

Get document styleSheet objects with for loop

for (var i=0; i < document.styleSheets.length; i++){
  var styleSheet = document.styleSheets[i];
}

Get all CSS rules for the document using Array methods

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;
            }
        }, '');

Specifications

Specification Status Comment
CSS Object Model (CSSOM)
The definition of 'CSSStyleSheetList' in that specification.
Working Draft  

Schlagwörter des Dokuments und Mitwirkende

Schlagwörter: 
 Mitwirkende an dieser Seite: Ephys, red-X, KthProg, groovecoder, teoli, Reachmeatshivam, kscarfone, ethertank, Sheppy, Zig
 Zuletzt aktualisiert von: Ephys,