javascript

Implementing show/hide popup box on mouse click


I have implemented the show part properly. But how to implement the hide of popup on click of anything on the page? And moreover there is a link, on click of which this will expand and collapse also.


Solution

    1. Attach an event hanlder to the popup element. On click of that stop event bubbling.

    2. Attach an event handler to document. On click of that hide the popup.

    A sample using jQuery

    Updated sample