I’ve read that the live function is deprecated and one should use the on method instead.
So I edited my code from
$('form').live('submit', function (event) {})
to
$('form').on('submit', function (event) {})
and it doesn’t work anymore 🙂 I’m wondering why ?
BTW the form element is added dynamically.
You need to attach the event handler to an element which exists in the DOM on page load:
You should substitute
bodyfor an element which is closer to theform, this way the event only has to bubble up one level, thus increasing performance, for example:-Then you would use:
All of this information can be found in the documentation