i want to be able to get all the class names of all css files on the page. Is there any existing possibility or do i have to read it and parse it by myself. Isn´t there any api of the browser?
1 Answer
is maybe a dulplicate request of this? How do you read CSS rule values with 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')
1 Comment
Luke
Hej thank you, it´s not the exact answer, but it told me what i needed to now. I needed the document.styleSheets -> rules -> selectorText. If you want, you can change your code so I get all selectorText items in one list. +1
class="..."names?classattributes on<link>elements that arerel=stylesheet?