javascript add class to element

JavaScript
var element = document.getElementById('element');
element.classList.add('class-1');
element.classList.add('class-2', 'class-3');
element.classList.remove('class-3');var someElement= document.getElementById("myElement");
    someElement.className += " newclass";//add "newclass" to element (space in front is important)const addClass = (element, name) => {
    const arr = element.className.split(" ");
    if (arr.indexOf(name) === -1) {
        element.className += " " + name;
    }
};function myFunction() {
  var element = document.getElementById("myDIV");
  element.classList.add("mystyle");
}
Source

Also in JavaScript: