views:

114

answers:

4

Sorry, Ill try simplify my question. Basically, when a user goes to a page...all the divs on the page and the content of the div fade in. Once loaded. I was thinking maybe something like:

$(window).load(function(){ 
  $('#div').load(function () { 
    $(this).fadeIn(4000); 
  });
}); 

cheers

+1  A: 

Perhaps something like this will do what you need:

$(function() { // execute when DOM Ready:
  $("#div").load("someOtherFile.html", function() { 
    $(this).fadeIn(4000);
  }).hide();
});
gnarf
I like your thinking but this maybe to complex. As im doing a shopping cart site with lots of pages. I would prefer a nice tidy script the lives in the head of every page of the site. So when any page is viewed the contents of the site fades in once loaded. .
daniel
A: 

So you're not loading in any dynamic content, right? Have you tried, simply:

$(window).load(function(){ 
   $('#div').fadeIn(4000);
});

$(window).load shouldn't fire until the whole page is loaded anyway--you shouldn't need to test again for the div/img. Doing so might be leading to some weirdness. You want this placed outside of $(document).ready(). See: http://4loc.wordpress.com/2009/04/28/documentready-vs-windowload/

D_N
tried your code.$(window).load(function(){ $('#div').fadeIn(4000);});it did not work for some reason. But i had success with $(document).ready(function() { $("#panel-two").fadeIn("3000"); });which loads in individual divs. as long as they are set to display none. So i have quite a fair bit of code in my head due to this method but it works.
daniel
A: 

Perhaps this was so simple it was overlooked, but to at least clarify the first code posting for others, the line:

$('#div').fadeIn(4000); Would only work on . It may or may not work on descendante tags, depending upon their properties.

if you selected $('div').fadeIn(4000); that would perform the function on all div tags at once. And

$('.div').fadeIn(4000); Would work on all objects with a class named 'div:

Regards,

James Fleming
A: 

James is correct, change your code to:

$(window).load(function(){ 
   $('div').fadeIn(4000);
});

using $('#div') only selects elements with an id of 'div'

path411