I don't understand why this method exists....
http://api.jquery.com/on/
It seems to me you'd always just do $(el).click()
instead of $(el).on('click', function...
$(el).on
gives the developers an unified way of binding events for any event types, direct and delegated events. It also allows you to bind more than one events at the same time by passing an object (2nd example in the documentation)
You also save a few keystrokes, for what it's worth.
With .on()
you can bind more than one event type at the same time, so you don't have to duplicate code or create a separate function if you want to do the same thing on multiple events.
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