What is the difference between using . on() and . click()?

Asked

Viewed 25 times

1

What’s the difference between declaring an Event Listener with jQuery to pick up the click on an element this way:

$("#elemento").on("click", function() {
    ...
});

And in this other way:

$("#elemento").click(function() {
    ...
});

It’s the same?

  • 1

    It’s the same thing. The difference is that one is shorter than the other.

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.