Skip to content

Instantly share code, notes, and snippets.

@zhuzhuaicoding
Created October 27, 2012 06:20
Show Gist options
  • Select an option

  • Save zhuzhuaicoding/3963191 to your computer and use it in GitHub Desktop.

Select an option

Save zhuzhuaicoding/3963191 to your computer and use it in GitHub Desktop.
getStyle compatibility
/* It is not possible to get certain styles set in css such as display using
the normal javascript. So we have to use this function taken from:
http://www.quirksmode.org/dom/getstyles.html */
function getStyle(el,styleProp)
{
var x = document.getElementById(el);
if (x.currentStyle) // IE
var y = x.currentStyle[styleProp];
else if (window.getComputedStyle) // FF
var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
return y;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment