<div class="cl1">test</div>
<button onlick="change()">change</button>
// javaScript part
let elemnt = document.getElementsByClassName("cl1")
function change(){
// "add" is gonna add classe one time if you click again class is not gonna remove if you want to change class and remove it with 2 click use toggle
// add
elemnt.classList.add("cl2")
// toggle
elemnt.classList.toggle("cl2")
}
document.addEventListener('click', function handleClick(event) {
console.log('user clicked: ', event.target);
event.target.classList.add('bg-yellow');
});