I have the following code
$(".Div2").click(function () {
$(this).css("background-color","yellow");
});
It works perfectly for me when I click it changes to yellow, how could I return to the original color when I click or double click again.
any suggestion
Thank you so much.
You could create a class with the color you need, and then add or remove the class according to the event that occurs (click, double click, etc).
Example:
You can see what he
background-color
hasdiv
and according to that make a conditional and leave the color as it was, I leave you an example:It should be said that the property
.css("backgroundColor")
will return a string of type: