请教问鼠标点击层外该层隐藏怎么写呀?用jquery怎么写? rt 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 层外跟隐藏层是什么关系?能说具体点吗 ,最好有html代码 回1楼:<form>...<div id='div1'><div>...</from>...部分代表div1层外 层外发生鼠标单击事件则隐藏div1 层内单击则不隐藏 請樓主試試<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=utf-8" /><title>无标题文档</title><style>#div1{ width:100px; height:100px; background:#f00;}</style><script>window.onload = function(){ var isOut = true; var dom = document.getElementById('div1'); var other = window.document; other.onclick = function(){ if(isOut){ dom.style.display = 'none'; } isOut = true; } dom.onclick = function(){ isOut = false; this.style.display = 'block'; }}</script></head><body>點擊(除div本身外)的任何地方關閉div1<br><div id="div1">我是div1</div></body></html> 哦,對不起!沒注意樓主你要的是支持jquery,呵呵... jquery代码:$(function(){$("#div2").click(function(){ $("#div1").hide();//隐藏id=div1的内部div });});<div id="div2" style="width:100px;height:100px;border:1px solid red;margin:1px;"><div id='div1' style="width:50px;height:50px;border:1px solid blue;margin:1px">div1<div></div> $("#div").on("click",function(){ return false;//阻止冒泡});$(document).on("click",function(){ $("#div").hide();}); 帮忙解释一下这个正则匹配的结果 Extjs 更新数据后怎么样显示更新后的数据 javascript 怎么获取cookie 如何在网页中嵌入一个JAVABEAN控件? 求个简单的正则 关于JS中的冒号用法 【window.onscroll问题】长时间不操作页面,等再次操作时上下滚动不再触发window.onscroll 求助deleteRow之后重命名未刷新!在线等 有不用层实现maromedia.com网站上的导航吗? 如何在网页上过滤“王志东” 求教uploadify3.1的formdata问题 为什么 innerHTML 生成的代码,在触发另外一个函数之后就消失了?
<form>
...
<div id='div1'>
<div>
...
</from>
...部分代表div1层外 层外发生鼠标单击事件则隐藏div1 层内单击则不隐藏
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>无标题文档</title>
<style>
#div1{ width:100px; height:100px; background:#f00;}
</style>
<script>
window.onload = function(){
var isOut = true;
var dom = document.getElementById('div1');
var other = window.document;
other.onclick = function(){
if(isOut){
dom.style.display = 'none';
}
isOut = true;
}
dom.onclick = function(){
isOut = false;
this.style.display = 'block';
}
}
</script>
</head>
<body>點擊(除div本身外)的任何地方關閉div1<br><div id="div1">我是div1</div>
</body>
</html>
$("#div2").click(function(){
$("#div1").hide();//隐藏id=div1的内部div
});
});<div id="div2" style="width:100px;height:100px;border:1px solid red;margin:1px;">
<div id='div1' style="width:50px;height:50px;border:1px solid blue;margin:1px">
div1
<div>
</div>
return false;//阻止冒泡
});
$(document).on("click",function(){
$("#div").hide();
});