javascript get element class code example
Example 1: javascript change element class
//Overwrite all classes
element.className = "class";
//Add class
element.classList.add("class");
Example 2: javascript get class name
document.getElementById("myDIV").className = "mystyle";
Example 3: js get class property
let element = document.querySelector('.preset');
let style = getComputedStyle(element);
let bg = style.backgroundColor;