DOM:window.getComputedStyle
From MDC
Contents |
[edit] Summary
Returns computed style of the element. Computed style represents the final computed values of all CSS properties for the element.
[edit] Syntax
var style = window.getComputedStyle(element, pseudoElt);
-
elementis an element. -
pseudoEltis a string specifying the pseudo-element to match. Should be an empty string for regular elements. -
styleis aCSSStyleDeclarationobject.
[edit] Example
var element = document.getElementById(“elemId”); var style = document.defaultView.getComputedStyle(element, pseudoElt);
[edit] Description
The returned object is of the same type that the object returned from the element's style property, however the two objects have different purpose. The object returned from getComputedStyle is read-only and can be used to inspect the element's style (including styles from a <style> tag or stylesheet). The elt.style object should be used to set styles on a specific element.
The first argument must be an Element, not a Node (as in a #text Node).