Reputation: 1686
I know that .click(function())
doesn't work on dynamic objects, but .on('click', function())
does, given the circumstance.
Is there any downside to using .on('click')
all of the time?
I've become accustom to using .on
to handle all of my events, regardless of whether it's dynamic or not.
Upvotes: 1
Views: 60
Reputation: 2403
These are just two different ways of adding an event handler,
See here: http://jsperf.com/jquery-on-versus-click/2
They are almost identical, but .on('click', function()
seems to be faster by the smallest amount.
.click(function()
143,775
±5.23%
fastest
vs
.on('click', function()
148,059
±5.66%
fastest
Upvotes: 2