XML DOM addRule() method

Definition and usage

The addRule() method inserts a rule into the stylesheet, which is a method specific to IE.

Syntax:

addRule(selector,style,index)
parameter Description
selector Required. The CSS selector of the rule.
style

Required. Styles applied to the elements that match the selector.

This style string is a list of property: value pairs separated by semicolons. It does not use curly braces to start or end.

index

Optional. The position where the rule is inserted or appended in the rule array.

If this optional parameter is omitted, the new rule will be added to the end of the rule array.

Description

This method specifies the position in the rules array of the stylesheet index Insert (or append) a new CSS style rule. This is a specific IE alternative to the standard insertRule() method.

Note:The parameters of this method are different from those of the insertRule() method.

Related pages

XML DOM reference manual:CSSStyleSheet.insertRule()