Possible Duplicate:
jquery on vs click methods
I understand that $(parent).on('click', 'element', function(){ ... is used to attach a click handler to an element that is dynamically created – while $('element').click(... only works if the element is present at inital page load. As of lately I always use .on() for everything because it covers both – my question is – is there any time where .click is preferred , or any other advantages that I may not know of to not using .on()
Actually
.click()is handled by.on(), see: https://github.com/jquery/jquery/blob/master/src/event.js#L1014So the only reason to prefer
.click()– is to have shorter code