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


source to share





All Articles