We Recommend

Pro JavaScript Techniques Pro JavaScript Techniques
Pro JavaScript Techniques is the ultimate JavaScript book for the modern web developer. It provides everything you need to know about modern JavaScript, and shows what JavaScript can do for your web sites. This book doesn't waste any time looking at things you already know, like basic syntax and structures.


Posted By

micmath on 02/11/08


Tagged


Versions (?)


Who likes this?

1 person has 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.