jQuery event for images loaded

后端 未结 14 1226
离开以前
离开以前 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:52

    You can use my plugin waitForImages to handle this...

    $(document).waitForImages(function() {
       // Loaded.
    });
    

    The advantage of this is you can localise it to one ancestor element and it can optionally detect images referenced in the CSS.

    This is just the tip of the iceberg though, check the documentation for more functionality.

提交回复
热议问题