can anyone tell me when I should use .on() method and when should I use .click() method ??!
thanks in advance
Use .on
if you want to bind to events other than clicking. .click
is just short for .on('click', ...)
, AFAIK (since binding to click events is so common)
1 Like
To add to what @kevcomedia said, the .on()
method creates one event for all the matched elements. Instead, the .click()
method creates a separate event for each matched element.
Also, with the .on()
method you can create delegated events, which can be very useful if you’re dealing with dynamic content.