请教问鼠标点击层外该层隐藏怎么写呀?用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();}); 真的好奇怪啊!!!!!!JS问题 js写法 [分享]Extjs框架学习资源 window.open() ff JavaScript效果,隐藏IE功能。带图片,知道的进来拿分哦。 编译器中未包含mian类型 为什么js显示不了阿拉伯语字母,只能显示字符实体? 谁能用梅花雪树型控件弄成csdn这种效果给100分! url换成js用什么工具怎么做 ajax读取图片字节流后在指定路径还原输出 求教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();
});