Difference between handlers

Asked

Viewed 22 times

1

Using JQuery, I realize two main ways to define handlers for element events:

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

and

$(document).delegate('#elemento','click',function() { ... });

I’ve been through situations where only one of the two worked on a certain element, why does that happen? What is the difference between their functionality and between them in general? Which should I give preference to?

No answers

Browser other questions tagged

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