Why jQuery loses 'event' (click) when some content has been loaded?

元气小坏坏 提交于 2019-12-04 09:16:39
$('.fatherDiv').on('click','.childDiv', {} ,function(e){
 //insert your code here
})

This will bind the event handlers to the DOM selector elements not only now, but also in future (selectors added to DOM after the bindings). Now the click event fires even the specific selectors are added or replaced with new DOM elements.


Read here for further info:
http://blog.revathskumar.com/2013/10/jquery-on-avoid-losing-event-binding-for-ajaxed-contents.html

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