Delay of some jQuery function until all images are fully loaded

How to delay some jQuery / JavaScript function until all the images on the page have finished loading? In fact, the jQuery function I'm talking about is designed to set the offset position for a div. The problem is that the page resizes after the images are fully loaded, so the offset is wrong.

For the jQuery function, refer to this question: Problems with a fixed div at the bottom of the page that stops at this location

+1
source share
2 answers

You can use the event onloadthat fires after all images or external resources are loaded:

$(window).load(function(){
  // your code here, all images loaded
});

load :

$('img.ImageClass').load(function(){
  // The image loaded....
});
+9

,

function newfunction(){
//put all the stuff here
}

,

$('img').load(function(){
newfunction()
})

.

+1

All Articles