Join MDN and developers like you at Mozilla's View Source conference, 12-14 September in Berlin, Germany. Learn more at https://viewsourceconf.org

この記事はまだボランティアによって 日本語 に翻訳されていません。ぜひ MDN に参加して翻訳を手伝ってください!

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

ドキュメントのタグと貢献者

 このページの貢献者: KthProg, groovecoder, teoli, Reachmeatshivam, kscarfone, ethertank, Sheppy, Zig
 最終更新者: KthProg,