If the src
is already set then the event is firing in the cache cased before you get the event handler bound. To fix this, you can loop through checking and triggering the event based off .complete
, like this:
$("img").one('load', function() { // do stuff }).each(function() { if(this.complete) $(this).load(); });
Note the change from .bind()
to .one()
so the event handler doesn't run twice.
Read full article from jQuery callback on image load (even when the image is cached) - Stack Overflow
No comments:
Post a Comment