Skip to content Skip to sidebar Skip to footer

Delay Some Jquery Function Until All Images Are Loaded Completely

How do I delay some jQuery / JavaScript function until all the images on a page have finished loading? Actually, the jQuery function I'm talking about is for setting the offset pos

Solution 1:

You can use the onload event which runs after all images or external resources are loaded:

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

You can also use the load event for individual images and run your code when they have loaded:

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

Solution 2:

just write the function under a variable like

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

after that call this function on every image load like

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

from this the newfunction will call everytime a new image load.

Post a Comment for "Delay Some Jquery Function Until All Images Are Loaded Completely"