Event stream event capture and event bubbling ----

Sometimes mixed feelings, but one hundred die debate, those things very far, as if just yesterday,

Writers in the painting of the night, leaving passers-by wonder

Event stream event capture and event bubbling ----

 

 

First, when the crap we need to understand a thing, this thing is an event stream. 

1. What is the flow of events? 

  Explanation: When an HTML element to trigger an event handler, the event will be the root node to the spread between the elements, propagation path through which nodes will receive the event, such a communication process called DOM event flow. 

  Simple explanation: the element that triggered the event, the process of propagation is called the event flow. 

  Event stream is divided into: event bubbling and event capture 

2, what is the event bubbling? 
  Explanation: The event bubbling can be likened to the image of a stone thrown into the water, the bubbles will always emerge from the bottom surface of the water, which means that the event will take place from the beginning of the innermost element, until the spread upward, to know the root 

  Microsoft proposed event bubbling 

3, event capture what is? 
  Explain: Suppose you are a disciple cover their crotch send the outer march clashed with the time (assuming that is the misty peaks) with other people, then the people must misty peaks first time will find a martial art where you are. Then find your master in find you, 
  and then shake hands with you (pure nonsense, in reality, be sure you hit your mother did not even know you), such a process is to look for event capture 

  a simple explanation: the event spread by the parent element to the child element of the transfer process, called the event capture 

  the event raised Netscape capture

 

4, the browser default order execution and dissemination events, first let's look at the event from bubbling execution order and execution

 

 css

 

 js

 

 When we went to order click oSmall when the event is executed: oSmall ----> oBig -----> body ----- document


Next we look at the order execution event capture and execution (css html code unchanged) 
JS

 

 When the order to click oSmall when we performed for the event: document ----> body -----> oBig ----- oSmall

  Order summary browser's default execution and dissemination events are: 

  the Document -----> HTML -----> ----- body> .........----> target element capture process 
 
  target element ----> .........-----> body ----> html ----> document bubbling process

 

Guess you like

Origin www.cnblogs.com/home-/p/11588643.html