Events only bubble up, but sometimes one needs to trigger a custom event on a parent element and make it call all the handlers on any of its children if they have a listener bound to them. What's the best way to do this in jQuery?
so far I came up with this:
$(startingParentElement).addBack().find('*').each(function(index,element){
$(element).triggerHandler('myCustomEventName');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With