I have a switch button like this:

I want to make it so that it is a dark mode button. When clicking once, it uses jQuery to invert the colors of specified class and 2, when you click again, it returns to the default. Here's how I plan to do it. I have a variable, clicks, that increase on the first click by one. When the button is clicked again, I want JS to detect that it was clicked and clicks == 1;
I have a few questions,
Is there a way to do that, if( detect clicked phase && clicks == 1;){} Assuming there is a way to do so, is there a way for jQuery to undo the actions of a previous button? For example, you click once, it makes everything dark. Click again and it makes everything back to normal? Thank you for any help.
Aucun commentaire:
Enregistrer un commentaire