Reputation:
I had another question similar to this but the answers seemed to miss out that I was trying to find the <HTML>
tag and modify it.
They suggested:
elem.className = elem.className.replace(/\blight\b/," dark ");
But with javascript how can I get the <HTML>
tag as the elem variable?
Upvotes: 0
Views: 51
Reputation: 11671
The following code returns the html element
document.documentElement
Upvotes: 1
Reputation: 100175
to get <html>
tag you could just do:
var elem = document.getElementsByTagName("html")[0];
or
var elem = document.querySelector("html");
or
var elem = document.body.parentNode;
Upvotes: 2