add onclick to class javascript code example
Example: how to add class to element on mouseclick with js
// element.classList.add("newClass");
// or
// element.className += "newClass";
// Example
document.querySelector("button").onclick = function addNewClass() {
document.querySelector(".elementToChange").classList.add("newClass");
}