pablocattaneo
7/23/2018 - 8:00 PM

How to detect a click outside an element?

$(document).click(function(event) { 
    if(!$(event.target).closest('#menucontainer').length) {
        if($('#menucontainer').is(":visible")) {
            $('#menucontainer').hide();
        }
    }        
});