The event broadcast in JS is divided into three phases: event capture, event-handling invocation, event bubbling.
1. Event capture: Walk down the DOM tree to the inside of a node
2. Event invocation: An event handler defined on a node (e.g. click Mouseove, etc.)
3. Event bubbling: Move up from this node along the DOM tree. (This will call the parent element's event-handling call, which can be used with stoppropagation in IE cancelbubble)
Look at the third parameter of AddEventListener () after you know the event broadcast. is a Boolean value, and False is event bubbling (that is, in phase Three), and true is event capture (that is, in the first phase).
In fact, there are only two parameters, but IE is event bubbling, so the third parameter is defined. However, the order of IE event bubbling is more in line with People's Daily thinking (so IE is not useless), so it is wrong to change.
But what's the point?
When it went to phase three, the problem came.
If the parent-child node has click event Handling, when we click on the child node.
Will first call the child node's click,
This will bubble to the parent node.
Then call the parent node's click.
But we don't need the parent node click.
At this time need to call Stoppropagation (), in IE to use cancelbubble ();
The end of this article
The Code is poetry.