16.6 Scripting Stylesheets
So far, we’ve seen how to set and query the CSS styles and classes of individual elements. It is also possible to script CSS stylesheets themselves. This is not commonly done, but it can occasionally be useful and this section sketches out the technique.
When scripting stylesheets, there are two kinds of objects you may need to work with. The first kind are the Element objects that representandelements that contain or reference your stylesheets. These are regular document elements and if you give them id attributes, you can select them with document.getElementById(). The second kind of object is a CSSStyleSheet object that represents the stylesheet itself. The document.styleSheets property is a read-only array-like object containing CSSStyle-Sheet objects that represent the stylesheets associated with the document. If you set the title attribute of theorelement that defines or references the style-sheet, that title will be available as the title property of the corresponding CSSStyle-Sheet object.
The subsections that follow explain what you can do with these style and link elements and stylesheet objects.欢迎转载,转载请注明来自一手册:http://yishouce.com/book/1/27731.html