admin管理员组

文章数量:1291123

I am trying to make my homepage consistently have a fade in effect when this loads. however, it only works part of the time. This is the current script I am using. I set it to html, since individual div elements didn't seem to work, but setting it to html does and doesn't.

$(document).ready(function () { $('html').hide().fadeIn(1500).delay(6000)});

I am trying to make my homepage consistently have a fade in effect when this loads. however, it only works part of the time. This is the current script I am using. I set it to html, since individual div elements didn't seem to work, but setting it to html does and doesn't.

$(document).ready(function () { $('html').hide().fadeIn(1500).delay(6000)});
Share Improve this question asked Sep 3, 2013 at 1:55 bennybenny 4742 gold badges7 silver badges16 bronze badges 8
  • We are going to need to see a live example of it not working.. or just more coding. – Josh Crozier Commented Sep 3, 2013 at 1:57
  • What happens when it fails? – Dan-Nolan Commented Sep 3, 2013 at 1:57
  • Yes, and what I mean does and doesn't it that it fades in sometimes and sometimes it just statically loads without fading in. – benny Commented Sep 3, 2013 at 1:58
  • Nevermind, I got it working. Allocated the script to load first before other scripts. – benny Commented Sep 3, 2013 at 2:00
  • 1 @Blake I tried your script jsfiddle/TsYr7 ... It's working fine.. – Ganesh Babu Commented Sep 3, 2013 at 2:03
 |  Show 3 more ments

4 Answers 4

Reset to default 2

set to priority before other scripts.

 $(document).ready(function () { $('body').hide().fadeIn(1500).delay(6000)});

Try the below code. It will work:

Set ur body first:

<body>
This is my page
</body>

Now the jQuery:

$(document).ready(function(){$("body").hide().fadeIn(1000);});

Check out some Loading effect at CODROPS Article .. u may find it useful http://tympanus/codrops/2013/09/18/creative-loading-effects/

It won't work if the page loads too slow.

Maybe a lot of images(large photos), scripts etc.

Or just because the slow internet connection.

本文标签: javascriptFade in effect on page loadStack Overflow