如何判断e.target在且套div内 <div id="a"><div><div>。。这里有很多div<br></div></div></div>如果一次click判断 是在div#a 之外 还是 在 div#a 之内类似于mouseleave, 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <title>floatDiv2.html</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <style type="text/css"> #show { border: 1px solid black; background-color: #E5F0FB; position: absolute; width: 150px; height: 100px; display: none; } </style> <script type="text/javascript" src="jquery.js"></script> <script type="text/javascript"> $(function () { $(document).click(function (e) { if (e.target.id != "show") { $("#show").hide(); } }); $("a").click(function (e) { $("#show").css({left: e.clientX, top: e.clientY}).show(); return false;//防止冒泡 }); }); </script> </head> <body> <a href="#">click me</a> <div id="show"></div> </body></html>or$("div").click(function () { jQuery.contains(this, $("#a")[0]);}); ie用元素的contains()函数Firefox下包含以下代码:if(typeof(HTMLElement)!="undefined") HTMLElement.prototype.contains=function(obj) { if(obj==this)return true; while(obj=obj.parentNode) if(obj==this)return true; return false; } <script>var ac=false;</script><div id='a' click='ac=true;'>....</div>最后在吧ac设置为false hookee 很深入啊KK3K2005 很简洁 如何在DIV中插入图片? 求一个js复选框树 JS中如何将字符串转换为日期类型,然后求两个日期相差多少天。在线等。 下拉框问题联动问题...!!急!急!! 100分救急,当完全移出菜单区域的时候菜单还原当前位置 关于网站浏量统计 我用JSP做留言本 请把下面的JSSCRIPT大小写转换程序转换成VBSCRIPT程序 有关让<div>和</div>之间的内容不显示的问题 在工具条存在的条件的情况下,如何屏蔽掉后退前进项,或使他们失效呢?菜鸟急需! jquery请求问题 如何给切换菜单设定触发时间(延迟时间
<html>
<head>
<title>floatDiv2.html</title>
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="this is my page">
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<style type="text/css">
#show {
border: 1px solid black;
background-color: #E5F0FB;
position: absolute;
width: 150px;
height: 100px;
display: none;
}
</style>
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript">
$(function () {
$(document).click(function (e) {
if (e.target.id != "show") {
$("#show").hide();
}
});
$("a").click(function (e) {
$("#show").css({left: e.clientX, top: e.clientY}).show();
return false;//防止冒泡
});
});
</script>
</head>
<body>
<a href="#">click me</a>
<div id="show"></div>
</body>
</html>
or
$("div").click(function () {
jQuery.contains(this, $("#a")[0]);
});
Firefox下包含以下代码:
if(typeof(HTMLElement)!="undefined")
HTMLElement.prototype.contains=function(obj)
{
if(obj==this)return true;
while(obj=obj.parentNode) if(obj==this)return true;
return false;
}
var ac=false;
</script><div id='a' click='ac=true;'>....</div>最后在吧ac设置为false
KK3K2005 很简洁