div事件穿透~~~ 现有两个DIV 是嵌套关系, 分别都有单击事件,, 单击内层DIV 空白处, 内层DIV的事件未被执行, 外层的DIV 事件被执行了,, 有没有什么好的解决办法 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 就是说 我要我结果是 单击内层DIV空白处也执行 内层DIV的事件 不执行外层的 <script>function test(e,a){e = e || window.event;if (window.event) {e.cancelBubble = true;} else {e.stopPropagation();}if(!a) alert("外");else{alert("内"); }}</script><div style="background: #666699;width: 300px;height: 200px;" onclick="test(event)"> <div onclick="test(event,1)" style="background: #66EE99;width: 100px;height: 80px;"> </div></div>是不是这意思 ? <div style="width:100px; height:100px; border:1px solid #000" id="x"><div style="width:50px; height:50px; margin:0 auto; border:1px solid #ccc" id="y"></div></div><script type="text/javascript">document.getElementById("x").onclick=function(e){ alert("x") e = e || window.event; if (e.stopPropagation ) e.stopPropagation(); else e.cancelBubble = true;}document.getElementById("y").onclick=function(e){ alert("y") e = e || window.event; if (e.stopPropagation ) e.stopPropagation(); else e.cancelBubble = true;}</script>阻止事件冒泡 JS连数据库问题 这个Javascript导航栏,怎么控制它的栏目个数? js 读取UL标签中的ID获取不到 关于JS弹出式窗口的问题,我是菜鸟,谁帮帮我,谢谢! 用JS如何判断页面是否加了W3C声明 到底怎么写?function swap(x) {document.(x+"sss").src="src";} 读取某url页面中的table的值,并保存下来。 高手请进呀:可行性问题===能否在网页中改变IE的页面设置 请问在JavaScript里能否嵌入ASP脚本? 请问:如何实现这样的滚动效果? jquery 有没有办法在input框后边追加一个层? js问题
<script>
function test(e,a){
e = e || window.event;
if (window.event) {
e.cancelBubble = true;
} else {
e.stopPropagation();
}
if(!a) alert("外");
else{alert("内"); }
}
</script>
<div style="background: #666699;width: 300px;height: 200px;" onclick="test(event)">
<div onclick="test(event,1)" style="background: #66EE99;width: 100px;height: 80px;">
</div>
</div>是不是这意思 ?
<div style="width:50px; height:50px; margin:0 auto; border:1px solid #ccc" id="y"></div>
</div>
<script type="text/javascript">
document.getElementById("x").onclick=function(e)
{
alert("x")
e = e || window.event;
if (e.stopPropagation )
e.stopPropagation();
else
e.cancelBubble = true;
}
document.getElementById("y").onclick=function(e)
{
alert("y")
e = e || window.event;
if (e.stopPropagation )
e.stopPropagation();
else
e.cancelBubble = true;
}
</script>
阻止事件冒泡