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:我发现我好像隐约有点印象,但是我给忘了

  • 相关阅读:
    Boost练习程序(强制转换)
    4873279(1002)
    A+B Problem(1000)
    STL练习程序(去除相同元素)
    Boost练习程序(智能指针)
    Sql技巧总结
    MySql Show Status详解
    mysql show status调优
    mysql decimal、numeric数据类型
    Apache Thrift学习小记
  • 原文地址:https://www.cnblogs.com/freesfu/p/14655334.html
Copyright © 2011-2022 走看看