Leia propriedades do arquivo CSS
.box {
position:absolute;
background-color:red;
height:10px;
width:10px;
}
Bored Beetle
.box {
position:absolute;
background-color:red;
height:10px;
width:10px;
}
function propertyFromStylesheet(selector, attribute) {
var value;
[].some.call(document.styleSheets, function (sheet) {
return [].some.call(sheet.rules, function (rule) {
if (selector === rule.selectorText) {
return [].some.call(rule.style, function (style) {
if (attribute === style) {
value = rule.style.getPropertyValue(attribute);
return true;
}
return false;
});
}
return false;
});
});
return value;
}
console.log(propertyFromStylesheet(".box", "height"));