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
        });
    });   

      

JSFIDDLE

How can I delegate an event error

??

+3
javascript jquery


source to share


No one has answered this question yet

Check out similar questions:

7428
How can I check if an element is hidden in jQuery?
4523
Thinking in AngularJS if I have a jQuery background?
4345
How to check if a checkbox is checked in jQuery?
3952
Setting "checked" for a checkbox with jQuery?
2644
Is there a function "exists" for jQuery?
2543
How can I check if an object is an array?
1898
$ (document). already equivalent without jQuery
1375
Where should I put <script> tags in my HTML markup?
1130
How do I select an element by name using jQuery?
931
How do I know which DOM element has focus?



All Articles
Loading...
X
Show
Funny
Dev
Pics