Event delegation is one of the most potent events handling patterns. It allows users to append a single event listener to a parent element that adds it to all of its present and future descendants that match a selector.
The main steps involve:
event.target
source element on the handlerLet’s append a handler on the following table that changes the font color to grey when a user clicks on the text.
Similarly, handlers can be applied to multiple elements throughout the document. Event delegation helps you to avoid redundant code and makes it shorter and easier to read.