jquery - hide div until all background images have loaded -


is there way wait until background images have loaded before code executed? know works 1 image how can adapt various images?

var firstbackgroundimage = new image();                          firstbackgroundimage.onload = function () {                         $('#main-slider').animate({opacity:1}),600;              };              firstbackgroundimage.src = "http://www.domain.com/img/iphone.png"; 

html

 <div id="main-slider"></div> 

css

#main-slider{    opacity:0; } 

thanks!

try:

$(window).load(function() {     // code gets executed when content of page (including images) loaded  }); 

Comments

Popular posts from this blog

java - activate/deactivate sonar maven plugin by profile? -

python - TypeError: can only concatenate tuple (not "float") to tuple -

java - What is the difference between String. and String.this. ? -