All css classes on a page using js

I want to be able to get all the class names of all the css files on the page. Is there any existing feature or do I need to read and disassemble it myself. Is there no avi browser?

+3
source share
1 answer

maybe this is a question requiring this? How do you read CSS rule values ​​using JavaScript?

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')
+2
source

All Articles