element.classList.replace(currentClass,newClass);
let containsClass = element.classList.contains('my-class'); element.classList.toggle('my-class', !containsClass);