Add attribute to HTML when BODY has a specific class
I was trying to style HTML when BODY gain a specific class. For that I need the HTML element would gain a specific attribute that css codes would recognize.
I wrote a script, but it doesn't work:
var elem = document.getElementByTagName('BODY');
var attr = elem.getAttribute('class');
if(attr !== null) {
if(attr == some_class")
document.getElementByTagName('HTML').setAttribute('my_attribute', 'true');
}
Add attribute to HTML when BODY has a specific class
I was trying to style HTML when BODY gain a specific class. For that I need the HTML element would gain a specific attribute that css codes would recognize.
I wrote a script, but it doesn't work:
Could someone help me with this?