The previous share proposed this event commissioned, today let me elaborate on the next.
Let's take a look at some examples:
<! doctype html> </script> </body> Here I give an unordered list, and we want to output a content after clicking on Li.
For most of us, it is possible to register the event directly on Li. But if this Li has thousands of words, that efficiency is conceivable.
The solution, then, is to use the events of the previous story to bubble up. Increase event monitoring on the top of Li's outermost ul. The event bubbles to the outermost layer as soon as you click inside Li.
And all we have to do is to determine which of the objects the object of the event is.
I use the method of judging nodes here, of course, students can also define the class name, with the JQ hasclass () method to determine the target object. In this way our events will be very efficient.
Front End-"learning experience"-Event delegation method