检测对象是否已加载[Javascript] [英] Detect if objects are loaded [Javascript]
本文介绍了检测对象是否已加载[Javascript]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道,有没有一种方法可以检测是否加载了某个图像/div? 例如,当我加载两个较重的图像并在图像稍后将占据的两个位置显示加载符号时,是否有办法在加载第一个图像时仍显示第二个图像?
I was wondering, is there a way to detect if a certain image / div is loaded? For example when i am loading two heavy images and showing a loading sign at the two places the images will later occupy, is there a way to already display the first image when it's loaded while still loading the second one?
推荐答案
myImage.addEventListener('load', function() { ... }, false);
图像加载完成后,将调用上述函数中的代码.
Code inside the above function will be called when the image is finished loading.
这篇关于检测对象是否已加载[Javascript]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文