Created
March 30, 2012 22:44
-
-
Save OndrejSlamecka/2256836 to your computer and use it in GitHub Desktop.
Get style property of DOM element using JavaScript
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* 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