Reputation: 409
I am trying to unbind event handlers (click) from all a-tags, and somehow it is not working. Do you guys know why?
// Remove eventhandlers
row.find('a').each(function(){
$(this).unbind('click');
alert($(this).attr("onClick"));
});
It will always output the current onClick function.
Thanks
Upvotes: 2
Views: 1360
Reputation: 21
$('a').unbind('click');
or
$('a').each(function() {
return false;
});
Upvotes: 0
Reputation: 322502
jQuery's .unbind()
only removes handlers assigned and maintained by jQuery. Your inline handlers are not affected.
If you want to remove an inline attribute, use removeAttr()
.
row.find('a').each(function(){
$(this).removeAttr('onClick');
alert($(this).attr("onClick"));
});
http://api.jquery.com/removeattr/
Upvotes: 4