我的内部有一个div,类似于
<form>
<div>
showing some information here
</div>
<div id="idshow" style="display:none">
information here
</div>
</form>
我是某些按钮单击事件中 div(idshow) 内的人口信息。每当我点击 div(idshow) 外部时我想要什么,它应该被隐藏。就像我单击菜单然后显示菜单一样,当我单击菜单外部时它会隐藏。 我需要使用 jquery 的一切
最佳答案
$(document).click(function(event) {
var target = $( event.target );
// Check to see if the target is the div.
if (!target.is( "div#idshow" )) {
$("div#idshow").hide();
// Prevent default event -- may not need this, try to see
return( false );
}
});
关于Jquery-隐藏div,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2928275/