如果鼠标在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/
你能用我的代码帮助我吗?谢谢
答案 0 :(得分:1)
这种方法适用于1.3:
$(document).click(function (e) {
$("#info").hide();
});
$('#info').click(function(e) {
e.stopPropagation();
});
这也有效:
$(document).click(function (e) {
if (!$(e.target).closest('#info').length)
$('#info').hide();
});