Someone once said that the art of being a good manager is to know when to delegate. I hope that this wasn't an excuse for them to offload a horrible job to a subordinate, although the cynical might say otherwise!
Leaving aside the risk, delegation follows the same principles in jQuery. If we need to create an application which requires binding some form of event handler to lots of elements of the same type, then we might consider writing event handlers to cover each element.
It'll work to an extent, but is very wasteful of resources. If the list is large, then events will be bound to all of the elements within, which uses more memory than is needed. We can get around this by using event delegation, where we can shift to binding one event handler to a single ancestor element that serves multiple descendants, or enable event handling for newly created elements.
There are a few tricks we can use to help us with better managing of events using delegation. Before we take a look...