Posted By

micmath on 02/11/08


Tagged


Versions (?)

Who likes this?

1 person have marked this snippet as a favorite

SpinZ


Get the actual style property value of an element


 / Published in: JavaScript
 

URL: http://www.quirksmode.org/dom/getstyles.html

Gets the style property as rendered, not as defined (which can be different).

  1. function measure(el, styleProp) {
  2. if (el.currentStyle)
  3. var st = el.currentStyle[styleProp];
  4. else if (window.getComputedStyle)
  5.  
  6. var st = document.defaultView.getComputedStyle(el, null).getPropertyValue(styleProp);
  7. return st;
  8. }

Report this snippet  

You need to login to post a comment.