javascript styleSheet addRule( )
addRule( ) | Firefox/Netscape/NN n/a IE 4 Chrome/Safari/DOM n/a |
addRule("selector", "style"[, index]) | |
Adds a new rule for a style sheet. This method offers a scripted way of adding a rule to an existing styleSheet object: document.styleSheets[1].addRule("p b","color:red"); |
|
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. |
|
Parameters | |
|
|
Returned Value | |
Early versions of IE returned no value. More recently, IE for Windows returns -1, while IE for Macintosh returns null. In the future, the returned value may become the integer of the index location of the new rule. |
Powered by Linode.