概述
轉自http://qiaolevip.iteye.com/blog/2087911
- <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").οnclick=function(e)
- {
- alert("x")
- e = e || window.event;
- if (e.stopPropagation )
- e.stopPropagation();
- else
- e.cancelBubble = true;
- }
- document.getElementById("y").οnclick=function(e)
- {
- alert("y")
- e = e || window.event;
- if (e.stopPropagation )
- e.stopPropagation();
- else
- e.cancelBubble = true;
- }
- </script>
最后
以上就是谦让心锁为你收集整理的Div嵌套防止穿透事件的全部内容,希望文章能够帮你解决Div嵌套防止穿透事件所遇到的程序开发问题。
如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复