事件流動(Event Flow)做爲事件(Event)一個很重要的機制,DOM事件不僅僅只會在一個Element上觸發,它還會流向其餘Element。spa
事件的流動一般會經歷這麼三個階段:捕獲階段 -> 目標階段 -> 冒泡階段對象
The event object propagate through the target's ancestors from the defaultView to the target's parent.事件
事件對象在事件目標的祖先中上到下順向傳播,從最頂層的defaultView到事件目標的(直系)父元素。get
捕獲階段發生在整個事件流動的開始。在這階段裏事件會從父(主幹)到子(分支)由上往下傳播,被元素一層層地捕獲。it
The event object arrive at the event object's event target.event
事件對象到達事件目標。object
若是事件是不可冒泡的,那整個事件流動會到此爲止,不會發生下面的冒泡階段。di
The event object propagates through the target's ancestors in reverse order, starting with the target's parent and ending with the defaultView.事件流
事件對象會在事件目標的祖先元素裏反向傳播,由開始的父元素到最後的defaultView(document)。document
冒泡階段發生在最後,這也是咱們最爲熟悉的一個階段。在這階段裏事件會從子(分支)到父(主幹)逆向傳播,看起來像是一個水裏的泡泡往上冒。