change colour onclick code example
Example 1: css onclick change color
<style>
.dabutton:focus {
background-color:yellow;
}
</style>
<button class="dabutton"></button> // <-- usage
Example 2: change color by click event javascript
var button = document.querySelector("button");
button.addEventListener("click", function() {
const curColour = document.body.style.backgroundColor;
document.body.style.backgroundColor = curColour === 'red' ? 'blue' : 'red';
});