欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  web前端

阻止JavaScript事件冒泡传递(cancelBubble 、stopPropagation)_javascript技巧

程序员文章站 2022-05-24 22:54:10
...
cancelBubble在IE下有效
stopPropagation在Firefox下有效
复制代码 代码如下:




阻止JavaScript事件冒泡传递(cancelBubble 、stopPropagation)





This is parent1 div.



This is child1.



This is parent1 div.






This is parent2 div.



This is child2. Will bubble.



This is parent2 div.