The following question has been already asked Read CSS rule values with JavaScript? - Nov 27 '08.
I tried the same code on my browser google chrome 19.0.1084.46
and firefox 12.0
and the script does not work.
Is there a new script, library, maybe using jQuery, to active the same task on the most recent version of browsers today ?
Here the code which does not work:
function getStyle(className) {
var classes = document.styleSheets[0].rules || document.styleSheets[0].cssRules
for(var x=0;x<classes.length;x++) {
if(classes[x].selectorText==className) {
(classes[x].cssText) ? alert(classes[x].cssText) : alert(classes[x].style.cssText);
}
}
}
getStyle('.test')
Here a link to the jsfiddle