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

自闭症网瘾萝莉.ら 提交于 2019-11-27 21:54:32
Samuel Liew
$('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.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!