I doing this way:
$.each($('img'), function () {
this.unbind('onmouseover');
});
This does not work. Why?
Try like below,
$('img').unbind('mouseover');
No need for looping.. and also it should be mouseover
not onmouseover
Assumptions: You are using .bind
to bind the mouseover
handler
I'm not using bind. some images have onmouseover attribute and I want to delete them. I tries $('img').removeAttr('onmouseover') but it still does not work
Code:
$('img').on('mouseover', function () {
//Your code
});
And later can unbind them by using .off
->
$('img').off('mouseover');
A work around for what you have (not preferred), (Reference)
$.each($('img'), function () {
$(this).removeAttr('onmouseover');
});
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With