Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
107
rated 0 times [  114] [ 7]  / answers: 1 / hits: 37530  / 15 Years ago, mon, september 14, 2009, 12:00:00

I have a floating div that gets displayed, and I want it to be hidden when the user clicks off the div. This would be similar to the .hover() function callback when hovering off an element. Only I want to do this for click.



I tried just setting a click event for the body, which would hide the div, but that gave unexpected results.



Anyone have ideas on how I could easily do this?


More From » jquery

 Answers
26

Another, possibly simpler, option would be to add a transparent div between the floating DIV and the rest of the page.



A simple click event on the transparent DIV could handle the hiding, and it would avoid the issues you are encountering with the click event.


[#98700] Wednesday, September 9, 2009, 15 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
marquezb

Total Points: 237
Total Questions: 97
Total Answers: 89

Location: Israel
Member since Wed, Apr 14, 2021
3 Years ago
;