user1031743
user1031743

Reputation: 329

jquery find descendants jquery 1.3.2

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

Answers (1)

Jason P
Jason P

Reputation: 27012

This approach works with 1.3:

http://jsfiddle.net/Gs46u/

$(document).click(function (e) {
    $("#info").hide();
});

$('#info').click(function(e) {
    e.stopPropagation();
});

This also works:

http://jsfiddle.net/8Wuxm/

$(document).click(function (e) {
    if (!$(e.target).closest('#info').length)
        $('#info').hide();
});

Upvotes: 1

Related Questions