JQuery function execute when all images are loaded

无人久伴 提交于 2019-12-13 03:59:28

问题


i need to execute a function when all images within a document are fully loaded i have try this


$(window).load(function() {....})

but this is not working properly in opera browser any other function that detect all images are loaded and also ignore if there is a missing image


回答1:


According to http://api.jquery.com/load-event/, you will want to bind the load event to the document and not the window. The load event will be fired for an object when all of its content and sub elements have been loaded. All of the page's content is part of the document object, and not window.

So to handle the event when all images on a page have loaded, do this:

$(document).load(function() {});

To handle the event when all images within a portion of the page have loaded, do this:

$("#pageSubSection").load(function() {});



回答2:


try $(document).load(function() {....});



来源:https://stackoverflow.com/questions/5410580/jquery-function-execute-when-all-images-are-loaded

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!