首页 > 其他 > 详细

事件冒泡,事件捕获和事件委托

时间:2018-04-07 17:03:57      阅读:247      评论:0      收藏:0      [点我收藏+]
  <div id="parent" onclick="checkCookie()">
    <div class="child" id="child"></div>
  </div>
    document.getElementById(‘parent‘).addEventListener(‘click‘,function(e){
      console.log(e)
      console.log(this.id + ‘被触发‘)

    },true);
    document.getElementById(‘child‘).addEventListener(‘click‘, function(e){
      console.log(e)
      console.log(this.id + ‘被触发‘)
    },true
    )

事件冒泡:4-7

事件捕获:1-4

技术分享图片

https://www.cnblogs.com/Chen-XiaoJun/p/6210987.html

事件冒泡,事件捕获和事件委托

原文:https://www.cnblogs.com/linsx/p/8733656.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!