Document. styleSheets [0]. What is the difference between rules and cssRules today when I use firefox, I suddenly find a small problem. The former is used for IE, and the latter is used for mozilla browsers.
<Style type = "text/css"> a {color: red} </style> script if(document.stylesheets%0%.css Rules) {plain Text)} else {plain Text)} script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]
In addition, the counting methods of rules and cssRules are different! Rules is the nth selector; cssRules is the nth rule. Run the following code using IE and firefox respectively.
<Style type = "text/css"> a, p, p {color: red} h5 {color: blue} </style> script if(document.stylesheets%0%.css Rules) {alert(document.stylesheets%0%.css Rules [1]. selectorText + ":" Export document.stylesheets%0%.cssrules%1%.style.css Text)} else {alert (document. styleSheets [0]. rules [1]. selectorText + ":" Your document.stylesheets%0}.rules%1).style.css Text)} script
[Ctrl + A select all Note: If you need to introduce external Js, You need to refresh it to execute]