|
|
|
|
|
Example 4: Using Stylesheets
The styleSheets property on the document object returns a list of the stylesheets that have been loaded on that document. You can access these stylesheets and their rules individually using the stylesheet, style, and CSSRule objects, as demonstrated in this example, which prints out all of the style rule selectors to the console.
ss = document.styleSheets; for(ii=0;ii<ss.length;ii++) { for(i=0;i<ss[0].cssRules.length;i++) { dump( ss[ii].cssRules[i].style.selectorText + "\n" ); }For a document with a single stylesheet in which the following three rules are defined:
BODY { background-color: darkblue; } P { font-face: Arial; font-size: 10pt; margin-left: .125in; } #lumpy { display: none; }This script outputs the following:
BODY P #LUMPY
| mozilla.org | mailto:oeschger | bug 93108 |
|
|
|
|
|