Why I'm getting the jQuery error “TypeError: $(…).live is not a function ” in following scenario?

南楼画角 提交于 2019-11-28 11:58:04
Jamie Hutber

live() has been removed since version 1.9 and was deprecated since 1.7:

You'll be wanting on() now days

$('#friends').on("click", ".remove", document.getElementById("friends"), function(){  

where #friends is available on DOM ready. You can't bind on() on a dynamical loaded element.

Ajinder Singh

You can use the .on() instead of .live() (deprecated after Jquery 1.7)

$(document).on('event', 'selector', function() {}); replaces .live().

Eg:

$( document ).on( "click", "#elementId ", function(){  alert( "Do here what you want!" );  // jQuery1.7+    });

Live() has been removed since 1.9 from jquery. Please use on

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