Remove onmouseover event from all <img> tags
2 answers
Try for example
$('img').unbind('mouseover');
No need to go in cycles .. and also should be mouseovernotonmouseover
Assumptions: You use .binda handler to bindmouseover
I do not use bind. some images have an onmouseover attribute, and I want to delete them. I am trying $ ('img'). RemoveAttr ('onmouseover'), but it still doesn't work
- Using an inline event handler is not standard.
- Since you are using jQuery, you must bind the handler as shown below.
The code:
$('img').on('mouseover', function () {
//Your code
});
And later, you can untie them using .off→
$('img').off('mouseover');
$.each($('img'), function () {
$(this).removeAttr('onmouseover');
});
+7
, " " jQuery, . attach , .
, DOM ( ), ,
return false;
:
$('img')
.unbind('mouseover') //remove events attached with bind
.off('mouseover') //remove events attached with on
.die('mouseover'); //remove events attached with live
.each(function(i,el){ //and for each element
el.onmouseover = null //replace the onmouseover event
});
+5