views:

19

answers:

2

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

+4  A: 

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/

patrick dw
thank you very much!
Kel
@Kel - You're welcome. :o)
patrick dw
A: 
$('a').unbind('click');

or

$('a').each(function() {
  return false;
});
filster