how to add class in vanilla js code example
Example 1: js add class
var myElement = document.querySelector('#myElement');
myElement.classList.add('some-class');
myElement.classList.add('one-class', 'one-more-class');
myElement.classList.remove('any-class');
Example 2: addclass js vanilla
element.classList.add('className');
Example 3: javascript add class to element
var someElement= document.getElementById("myElement");
someElement.className += " newclass";
Example 4: add class to html tag javascript
var root = document.getElementsByTagName( 'html' )[0];
root.className += ' responsive';