Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Grab CSS styles with jQuery...
To call it:
getStyle(document.getElementById("container"), "font-size")
function getStyle(oElm, strCssRule){
var strValue = "";
if(document.defaultView && document.defaultView.getComputedStyle){
strValue = document.defaultView.getComputedStyle(oElm, "").getPropertyValue(strCssRule);
else if(oElm.currentStyle){
strCssRule = strCssRule.replace(/\-(\w)/g, function (strMatch, p1){
return p1.toUpperCase();
strValue = oElm.currentStyle[strCssRule];
return strValue;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment