But if there is such a code, it is recommended that you consult with the business first to find out the ins and outs before making a decision.
If nothing else happens, Even if the events of each li are different, I will add different styles, and then do event delegation on ul, and will not bind them one by one on li.
Event delegation can reduce the pressure of event listening. Secondly, when you load data asynchronously with event delegation, when the returned data is generated into a dom node, if the dom node happens to have an event, you need to bind the event. If you use event delegation, you only need to bubble up to the dom node. No need to bind the event again.
Code that needs to be refactored~~~
But if there is such a code, it is recommended that you consult with the business first to find out the ins and outs before making a decision.
If nothing else happens,
Even if the events of each li are different, I will add different styles, and then do event delegation on ul, and will not bind them one by one on li.
There are many examples online.
Event delegation can reduce the pressure of event listening.
Secondly, when you load data asynchronously with event delegation, when the returned data is generated into a dom node, if the dom node happens to have an event, you need to bind the event. If you use event delegation, you only need to bubble up to the dom node. No need to bind the event again.