Reputation: 329
I have a code to hide a div if the mouse clicks outside of inside a child element of div. However, it works only if I click outside. Works Ok with jquery 1.8 but I need to use 1.3.2 I need the element to be opened even if mouse clicks inside or this element or any of it's child elements.
$(document).click(function (e) {
if (e.target.id != 'info' && !$('#info').find(e.target).length) {
$("#info").hide();
}
});
http://jsfiddle.net/QStkd/640/
1.3.2 http://jsfiddle.net/J9Js5/
Can you help me with hthe code? Thank you
Upvotes: 0
Views: 31
Reputation: 27012
This approach works with 1.3:
$(document).click(function (e) {
$("#info").hide();
});
$('#info').click(function(e) {
e.stopPropagation();
});
This also works:
$(document).click(function (e) {
if (!$(e.target).closest('#info').length)
$('#info').hide();
});
Upvotes: 1