j查询查找后代 jquery 1.3.2.



我有一个代码,如果鼠标在div 的子元素内部单击,则隐藏div。但是,它只有在我单击外部时才有效。使用 jquery 1.8 工作正常,但我需要使用 1.3.2即使鼠标在里面单击或此元素或其任何子元素,我也需要打开该元素。

$(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/

你能帮我处理h代码吗?谢谢

此方法适用于 1.3:

http://jsfiddle.net/Gs46u/

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

这也适用于:

http://jsfiddle.net/8Wuxm/

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

最新更新