//Use element.classList.add to add a class: let element = document.getElementById("div1"); element.classList.add("otherclass");