I want to hide an element if it is clicked outside the element it self. als But it can't be closed if the menu button is clicked.
Now I have the following code:
$(document).mouseup(function test (e) {
var button = $('.menu-button').data('clicked', true);
var container = $(".sf-menu");
if (!container.is(e.target) && container.has(e.target).length === 0 && button.data('clicked') == false) {
container.hide();
}
});
But the problem seems to be in:
button.data('clicked') == false)
How to write this code correctly?
Thnx!