zoukankan      html  css  js  c++  java
  • 事件处理的三个阶段

    事件处理的三个阶段

    今天面试被问到这个问题,我听得一脸懵,啥三个阶段,我只知道触发事件,事件冒泡,别的还真不知道,上网搜索了一下,W3C的原文链接

    The capture phase: The event object propagates through the target’s ancestors from the Window to the target’s parent. This phase is also known as the capturing phase.

    The target phase: The event object arrives at the event object’s event target. This phase is also known as the at-target phase. If the event type indicates that the event doesn’t bubble, then the event object will halt after completion of this phase.

    The bubble phase: The event object propagates through the target’s ancestors in reverse order, starting with the target’s parent and ending with the Window. This phase is also known as the bubbling phase.

    简单来说事件处理分为三个阶段:

    1. 事件捕获阶段
    2. 事件响应阶段
    3. 事件冒泡阶段

    事件发生时:

    1. 第一步由window发出事件对象通过目标元素的祖先节点传播
    2. 第二步在事件对象到达目标元素以后,事件触发
    3. 第三步在事件触发以后事件对象按与事件捕获阶段相反的方向传播(子->父->window)

    PS:我发现我好像隐约有点印象,但是我给忘了

  • 相关阅读:
    sqlserver中函数和存储过程的区别
    sql 经典面试题
    sqlserver 时间处理函数
    在GROUP BY中"做文章"(五种中简答方法!)
    SQL 非等价连接
    GROUP BY 两个字段(或者多个字段的时候)
    WCF-错误集合001
    DOM
    DOM的排他功能及显示隐藏功能
    预解析
  • 原文地址:https://www.cnblogs.com/freesfu/p/14655334.html
Copyright © 2011-2022 走看看