To change the class you can use following functiionalities:
HTML:
<button id="myButton">Click me</button>
Javascript:
const button = document.getElementById('myButton');
button.onclick = function() {
button.classList.add('newClass');
};
CSS:
.newClass {
background-color: red;
color: white;
}