Skip to content

Instantly share code, notes, and snippets.

@OndrejSlamecka
Created March 30, 2012 22:44
Show Gist options
  • Save OndrejSlamecka/2256836 to your computer and use it in GitHub Desktop.
Save OndrejSlamecka/2256836 to your computer and use it in GitHub Desktop.
Get style property of DOM element using JavaScript
/**
* Returns styleProperty of given element
*/
function getStyle(el, styleProperty)
{
if (el.currentStyle)
return el.currentStyle[styleProperty];
else if (window.getComputedStyle)
return document.defaultView.getComputedStyle(el,null).getPropertyValue(styleProperty);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment