Here is my code: http://jsfiddle.net/XYbmE/75/
I want the div#first to stay blue if the black box is there. The black box only appear if i click on the div#first. If i click anywhere else the blackbox should be hidden and the div#first should be back red.
What should i do?
This looks like a job for classes!
When the click event is triggered, add a class to
#firstthat has the same CSS as:hover.And then, add the class on click:
Remove the class and black box, when you click elsewhere:
DEMO: http://jsfiddle.net/EjKKP/