change an html class with js code example
Example 1: change elements class javascript
document.getElementById("MyElement").classList.add('MyClass');
document.getElementById("MyElement").classList.remove('MyClass');
if ( document.getElementById("MyElement").classList.contains('MyClass') )
{
document.getElementById("MyElement").classList.toggle('MyClass');
}
Example 2: html get class property
let element = document.querySelector('.preset');
let style = getComputedStyle(element);
let bg = style.backgroundColor;