Skip to content Skip to sidebar Skip to footer

The Best Way To Add Eventlistener To An Element

I'm trying to find the most productive way to hanging event. Lets imagine we have this structure:
  • 1st li
  • ...
  • 99999th li <

Solution 1:

I wouldn't look at "big sites" for the best web development practices. The first way has really no advantages over the other two, as it mixes JavaScript with HTML and is harder to maintain.

Event delegation will be lighter than the other two and will have the advantage of being able to handle dynamically generated elements, so in this case, it'd probably be the best choice. I would profile your application with both approaches before choosing.


Solution 2:


Post a Comment for "The Best Way To Add Eventlistener To An Element"