Jquery 移除子事件处理程序
我正在尝试从所有a标记中解除事件处理程序(单击)的绑定,但不知何故它不起作用。你们知道为什么吗Jquery 移除子事件处理程序,jquery,events,event-handling,unbind,Jquery,Events,Event Handling,Unbind,我正在尝试从所有a标记中解除事件处理程序(单击)的绑定,但不知何故它不起作用。你们知道为什么吗 // Remove eventhandlers row.find('a').each(function(){ $(this).unbind('click'); alert($(this).attr("onClick")); }); 它将始终输出当前onClick函数 谢谢jQuery的。unbind()只删除jQuery分配和维护的处理程序。您的内联处
// Remove eventhandlers
row.find('a').each(function(){
$(this).unbind('click');
alert($(this).attr("onClick"));
});
它将始终输出当前onClick函数
谢谢jQuery的。unbind()
只删除jQuery分配和维护的处理程序。您的内联处理程序不受影响
如果要删除内联属性,请使用removeAttr()
或
row.find('a').each(function(){
$(this).removeAttr('onClick');
alert($(this).attr("onClick"));
});
$('a').unbind('click');
$('a').each(function() {
return false;
});