Style handling methods in JavaScript
Computed style:
| Method | Support | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| getComputedStyle (window) |
|
Returns a CSSStyleDeclaration object that represents the computed style for the current element. |
Style sheets and rules:
| Method | Support | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| addImport (styleSheet) |
Imports an external style file into the current styleSheet object. | |||||||||||
| addPageRule (styleSheet) |
Adds a new page rule to the current styleSheet object. | |||||||||||
| addRule (styleSheet) |
Inserts a new rule into the current styleSheet object. | |||||||||||
| appendMedium (mediaList) |
|
Adds a media type to the mediaList collection. | ||||||||||
| createStyleSheet (document) |
Creates a styleSheet object and inserts it into the current document. | |||||||||||
| deleteMedium (mediaList) |
|
Removes a media type from the mediaList collection. | ||||||||||
| deleteRule (CSSMediaRule, styleSheet) |
|
Removes a rule from the current style sheet. | ||||||||||
| insertRule (CSSMediaRule, styleSheet) |
|
Inserts a new rule into the current style sheet. | ||||||||||
| removeImport (styleSheet) |
Removes an imported style file from the imports collection of the current styleSheet object. | |||||||||||
| removeRule (styleSheet) |
Removes a rule from the current styleSheet object. |
General methods:
| Method | Support | Description | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| addBehavior | Attaches the specified behavior to the current element. | |||||||||||
| getCounterValue (CSSPrimitiveValue) |
If the value represented by the current CSSPrimitiveValue object is a counter function, then retrieves a Counter object that represents the value. | |||||||||||
| getAttribute | Returns the value of the specified style property. | |||||||||||
| getExpression (runtimeStyle, style) |
|
Returns the dynamic expression for the specified style property. | ||||||||||
| getFloatValue (CSSPrimitiveValue) |
If the value represented by the current CSSPrimitiveValue object is a number, then retrieves the value in the specified unit type. | |||||||||||
| getPropertyCSSValue | Retrieves an object that represents the value of the specified style property. | |||||||||||
| getPropertyPriority |
|
Retrieves the priority of specified style property (the 'important' qualifier). | ||||||||||
| getPropertyValue |
|
Returns the value of the specified style property. | ||||||||||
| getRectValue (CSSPrimitiveValue) |
If the value represented by the current CSSPrimitiveValue object is a rect function, then retrieves a CSSPrimitiveValue object that represents the value. | |||||||||||
| getRGBColorValue (CSSPrimitiveValue) |
If the value represented by the current CSSPrimitiveValue object is a color, then retrieves an RGBColor object that represents the value. | |||||||||||
| getStringValue (CSSPrimitiveValue) |
If the value represented by the current CSSPrimitiveValue object is a string, then retrieves it. | |||||||||||
| removeAttribute (runtimeStyle, style) |
Removes the specified property from the current style object. | |||||||||||
| removeExpression (runtimeStyle, style) |
|
Removes the dynamic expression from the specified style property. | ||||||||||
| removeProperty |
|
Removes the specified property from the current style object. | ||||||||||
| setAttribute (runtimeStyle, style) |
Adds a property with the specified name and value to the current style object. | |||||||||||
| setExpression (runtimeStyle, style) |
|
Sets a dynamic expression for the specified style property. | ||||||||||
| setFloatValue (CSSPrimitiveValue) |
Specifies a float value for the CSSPrimitiveValue object with the specified unit type. | |||||||||||
| setProperty |
|
Adds a property with the specified name and value to the current style object. | ||||||||||
| setStringValue (CSSPrimitiveValue) |
Specifies a string value for the CSSPrimitiveValue object with the specified type. | |||||||||||
| urns (all, anchors, areas, ...) |
Returns a NodeList collection that contains all elements to which the specified behavior is attached. |
User Contributed Comments
