how to add a class to html using javascript

JavaScript
var someElement= document.getElementById("myElement");
    someElement.className += " newclass";//add "newclass" to element (space in front is important)function myFunction() {
  var element = document.getElementById("myDIV");
  element.classList.add("mystyle");
}
Source

Also in JavaScript: