I have a button and I want to remove all the classes when it is clicked. Here is what I have tried:
button.style.className = ''
document.querySelector('button').onclick = function() {
this.style.className = '';
}
.myClass {
color:red;
}
.second {
color:green;
}
<button class="myClass second">click me</button>
Since I don't know the names of the classes as they are dynamic, I cannot use classList.remove. How can I effectively remove all classes from an element?