jQuery event for images loaded

后端 未结 14 1203
离开以前
离开以前 2020-11-22 15:25

Is it possible to detect when all images are loaded via a jQuery event?

Ideally, there should be a

$(document).idle(function()
{
}

14条回答
  •  北海茫月
    2020-11-22 15:58

    If you want to check for not all images, but a specific one (eg. an image that you replaced dynamically after DOM is already complete) you can use this:

    $('#myImage').attr('src', 'image.jpg').on("load", function() {  
      alert('Image Loaded');  
    });  
    

提交回复
热议问题