Hey there. The situation is like this:
- The user clicks a button.
- Tooltip pops up.
- The user clicks the button again OR the user clicks anywhere outside the tooltip.
- The tooltip is removed.
Now I can get either of the events described in step 3 to work, but I can't get them to work at the same time. My code is in short like this (I'm not copying all code, just explaining it, so not all functions that I mention are real functions as you will see ^^):
button onclick="function() // Checks if tooltip exists and if yes, removes it. If not, creates it.
(works, no need to show you the code I think).
$(window).click(function()
{
if(tooltip exists)
if(clicked outside the tooltip)
remove tooltip
});
Now the problem is (I think) that when the button is clicked the onclick="" is executed BEFORE the window.click function is executed, as the tooltip appears to exist (and is removed!) when the window.click function checks for its presence as soon as I click the button. When I change the window.click function to window.mouseup, the tooltip does not get removed when I click the button, but it does when I click outside the element, which is great. Only problem is that the tooltip now does not get removed anymore when I click the button again.. Help please!