onClick back to default

onClick back to default
0

#1

Hi,

I have an onClick event triggred. And I want to set it back to default by a second click. How do I do it?
In my code, by clicking the button, the background turns blue. On second click I want to set it back to white.
My code is here

Thank you very much in advance,

Sven


#2

You can use the classList.toggle to toggle the class of the element.

document.getElementById("check").classList.toggle("blue");