You can hook up to the click event of document and then make sure
#menucontainer
is not an ancestor of the clicked element (jQuery.closest()).
If it is not, then the clicked element is outside of the
#menucontainer
and you can safely hide it.$(document).click(function(event) {
if(!$(event.target).closest('#menucontainer').length) {
if($('#menucontainer').is(":visible")) {
$('#menucontainer').hide()
}
}
})
Hope it helps.
0 comments :
Post a Comment