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?
Related: What is the difference between . on("click", Function() {}) and . click(Function() {})?
– Marcelo de Andrade
Oh yes, as I put the title, the system did not suggest this other similar question, thank you
– Artur Trapp