jQuery or Javascript check if image loaded

后端 未结 5 1364
一整个雨季
一整个雨季 2020-11-27 18:14

I know there is a lot of these on Stackoverflow but I haven\'t found one that works for me in a recent version of jquery (1.10.2).

I did try:

$(\".lazy

5条回答
  •  感动是毒
    2020-11-27 18:40

    In the case of waiting of loading multiple images:

    var images = $("#div-with-images img");
    var unloaded = images.length;
    images.on('load', function(){
      -- unloaded;
      if (!unloaded) {
        // here all images loaded, do your stuff
      }
    });
    

提交回复
热议问题