javascript window getComputedStyle( )

getComputedStyle( )NN 6 IE n/a DOM 2  

getComputedStyle(elementNodeReference, "pseudoElementName")

  

Returns a style object (specifically, a CSSStyleDeclaration object in the W3C DOM terminology) showing the net cascade of style settings that affect the element passed as the first parameter. To retrieve a particular style attribute value (including a value inherited from the default browser style sheet), use the getPropertyValue( ) method of the style object returned from this method:

var compStyle = getComputedStyle(document.getElementById("myP"), "");
var pBGColor = compStyle.getPropertyValue("background-color");

See the style object for additional details.

 
Parameters
 
  • Reference to an element node in the document tree that becomes the selection.
  • String name of a pseudo-element (e.g., :first-line) or an empty string.
 
Returned Value

style (CSSStyleDeclaration) object reference.


2248,Nickname,Homepage or email,Comments here,Add comment