javascript styleSheet insertRule( )
insertRule( ) | Firefox/Netscape/NN 6 IE 5(Mac) Chrome/Safari/DOM 2 |
insertRule("ruleText", index) | |
Adds a new rule for a style sheet. This method offers a scripted way of adding a rule to an existing W3C DOM styleSheet object: document.styleSheets[1].insertRule("p b {color:red}", 0); |
|
You may duplicate a selector that already exists in the styleSheet and, therefore, override an existing rule for the same element selector. The only prohibition is that you may not override a rule to convert a plain style rule into one that creates a positionable element (or vice versa). The new rule is governed by the same cascading rules as all style sheet rules (that includes the rule's source code position among other rules with the same selector). Therefore, a new rule in a styleSheet object does not supersede a style set in an element's style property. Note that IE 5 for the Macintosh implements both the W3C DOM insertRule( ) and Microsoft addRule( ) methods to accomplish the same result. |
|
Parameters | |
|
|
Returned Value | |
Integer of the index location of the new rule. |
Powered by Linode.