Demo: http://jsfiddle.net/nazym/1/
The code meant to show a popup when button pressed and hide it when pressed anywhere else. The error happens when the button is clicked twice.
So the code should work on showing/hiding the popup when the button is clicked repeatedly.
Demo: http://jsfiddle.net/nazym/1/ The code meant to show a popup when button pressed and hide
Share
If you want to make it such that clicking the button shows the popup if it is hidden and hides it if it is shown (and clicking anywhere else hides it), it’s this block of your code that is causing the issue:
You are not passing in any arguments to your hideDropDown function. It should be:
That way, the onclick handler is properly added to the element.