When I first learned jQuery, I normally attached events like this:
$(\'.my-widget a\').click(function() {
$(this).tog
Event delegation is a technique to write your handlers before the element actually exist in DOM. This method has its own disadvantages and should be used only if you have such requirements.
When should you use event delegation?
Why you should not use event delegation?
PS: Even for dynamic contents you don't have to use event delegation method if you are bind the handler after the contents get inserted into DOM. (If the dynamic content be added not frequently removed/re-added)