How do I add the class name "foo" to the root <html> element without using jQuery (or a similar library)?
<html>
You can use the classList to access an element's list of classes.
document.documentElement.classList.add('my-awesome-class'); document.documentElement.classList.remove('my-awesome-class'); document.documentElement.classList.contains('my-awesome-class');
1.4m articles
1.4m replys
5 comments
57.0k users