This article helps you understand some of the event bubble knowledge.
I. What is event bubbling?
Trigger a certain type of event on an object (such as clicking an onclick event). If this object defines the event handler, this event will call this handler, if the event handler is not defined or the event returns true, the event will be propagated to the parent object of the object, from the inside out, until it is processed (all similar events of the parent object will be activated), or it reaches the top level of the object hierarchy, that is, the document Object (Some browsers are windows ).
For example, if you want to appeal a case in the local court, if the local court does not handle such cases, the local authorities will help you continue to appeal to the higher court, such as from the municipal level to the provincial level, to the Central Court, your case will be handled.
Ii. What is the function of event bubbling?
(1) event bubbling allows multiple operations to be processed in a centralized manner (add the event processor to a parent element to avoid adding the event processor to multiple child elements ), it also allows you to capture events at different levels of the Object layer.
[Centralized processing example]
The Code is as follows: