Javascript Reference
Categories: styleSheet

javascript styleSheet insertRule( )

@March 15, 2008, 1:22 a.m.
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
 
  • The entire style rule selector as a string in exactly the same format as assigned in a style element: selector {attribute:value; attribute:value;...}.
  • Zero-based integer indicating where in the cssRules collection the new rule should be placed.
 
Returned Value

Integer of the index location of the new rule.

generic lipitor <a href="https://lipiws.top/">lipitor 20mg for sale</a> lipitor 20mg pill
Wcuefm - 1 months
Under moderation.
CraigMek - 2018-01-25
Under moderation.
Shawnneind - 2017-08-30

Powered by Linode.