所有图像加载时执行JQuery函数 [英] JQuery function execute when all images are loaded

查看:106
本文介绍了所有图像加载时执行JQuery函数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  
我需要在文档中的所有图像完全加载时执行一个函数$(window).load(function(){....})

但这不是在Opera浏览器中正常工作检测所有图像的任何其他函数都会被加载,并且在图像丢失的情况下也会被忽略解决方案

根据 http://api.jquery.com/load-event/ ,您需要绑定加载事件到文档而不是窗口。当一个对象的所有内容和子元素都被加载后,加载事件将被触发。所有页面的内容都是文档对象的一部分,而不是窗口。



因此,要处理页面上所有图像加载时的事件,请执行以下操作: p>

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

要处理页面部分内的所有图像都已加载时的事件,请执行以下操作: p>

  $(#pageSubSection)。load(function(){}); 


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

解决方案

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() {});

这篇关于所有图像加载时执行JQuery函数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆