jquery callback after all images in dom are loaded?

前端 未结 3 619
野性不改
野性不改 2020-11-29 18:51

How can I fire an event when all images in the DOM are loaded? I\'ve googled a lot. I\'ve found this, but it doesn\'t seem to work:

jQuery event for images loaded

3条回答
  •  借酒劲吻你
    2020-11-29 19:11

    One issue I ran into with user113716's edited solution is that a broken image will keep the counter from ever reaching 0. This fixed it for me.

    .error(function(){
      imageLoaded();
      $(this).hide();
    });
    

提交回复
热议问题