Reputation: 18306
I have a sub-menu. I want to hide it when user clicks anywhere outside it. I try focusout() and blur() jQuery methods, but they don't work.
Upvotes: 0
Views: 169
Reputation: 5207
// listen click event on document
$(document).click(function(e){
// if the event is not triggered by your submenu, hide it.
if(e.target.id != id_of_sub_menu){
$("#id_of_sub_menu").hide();
}
});
Upvotes: 1
Reputation: 1
// here is div whose id is 'block'
$(document).ready(function() {
$('#block').mouseout(function() {
$(this).hide();
})
});
Hope it helps!!
Upvotes: 0