I write this code to hide div when user click anywhere in body outside this div.. but is wrong what is the problem ?
$('body').click(function() {
$('.mydiv').hide();
});
I write this code to hide div when user click anywhere in body outside this div.. but is wrong what is the problem ?
$('body').click(function() {
$('.mydiv').hide();
});
If u give like this
$('body').click(function() {
$('.mydiv').hide();
});
This DIV will get Hidden even if you click inside the DIV.
Instead of giving that function to the body
onclick
event, you can make two container divs: One for everything in the body above your menu, and one for everything below your menu within the body
tag, and give those two divs the onclick
function you're currently giving to the body
.