When I first learned jQuery, I normally attached events like this:
$(\'.my-widget a\').click(function() {
$(this).tog
Apparently, event delegation is actually recommended now. at least for vanilla js.
https://gomakethings.com/why-event-delegation-is-a-better-way-to-listen-for-events-in-vanilla-js/
"Web performance # It feels like listening to every click in the document would be bad for performance, but it’s actually more performant than having a bunch of event listeners on individual items."