Use jquery $ (document) .on () to delegate IMG error event
We can use $(document).on('event', 'selector', function)
to delegate events for each item associated with selector
.
But the same logic doesn't seem to work when I try to delegate error
.
$(document).on('error', 'img', function () {
console.log(1); // not working
});
$('img').bind('error', function(){
console.log(2); // working
});
$(document).ready(function(){
$('img').on('error', function(){
console.log(3); // working
});
});
How can I delegate an event error
??
+3
source to share
No one has answered this question yet
Check out similar questions: