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?
相关问题
- Is there a limit to how many levels you can nest i
- How to toggle on Order in ReactJS
- void before promise syntax
- Keeping track of variable instances
- Can php detect if javascript is on or not?
if an image is done loading, its
.complete
property switches to true.Code inside the above function will be called when the image is finished loading.
If you are using
new Image
to preload images, then you can do the following to be notified of then it is loadedRemember to set the
src
after theonload
.