change class function javascript code example
Example 1: Javascript change element class
document.getElementById("myElementID").classList.add('myClassName');
document.getElementById("myElementID").classList.remove('myClassName');
Example 2: javascript change element class
//Overwrite all classes
element.className = "class";
//Add class
element.classList.add("class");