Javascript Reference
Categories: styleSheet

javascript styleSheet addRule( )

@March 15, 2008, 1:22 a.m.
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
 
  • The style rule selector as a string.
  • One or more style attribute:value pairs. Multiple pairs are semicolon delimited, just as they are in the regular style sheet definition.
  • An optional integer indicating where in the collection the new element should be placed.
 
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.

atorvastatin pills <a href="https://lipiws.top/">buy atorvastatin generic</a> lipitor 80mg canada
Mmrelq - 9 months
Error 212 <a href=https://try.alexa.com/marketing-stack/competitor-keyword-matrix>origin is unreachable</a>
SandraReat - 3 years
Under moderation.
CraigMek - 2018-01-23

Powered by Linode.