jQuery - how to use the "on()" method instead of "live()"? [duplicate] jQuery - how to use the "on()" method instead of "live()"? [duplicate] jquery jquery

jQuery - how to use the "on()" method instead of "live()"? [duplicate]


$('body').on('click', '#element', function(){    $("#my").html(result);});

The clicked element selector is now passed through the .on() function parameters, and the previous selector should be replaced with the closest parent selector preferably with an ID. If you do not know what parent selector to use, body works too, but is less efficient.

see jQuery 1.9 .live() is not a function on how to migrate existing code.