Reputation: 9326
Ok, suppose I had a body element in my stylesheet and I set visibility:hidden;
When the page is loaded I would like to use .fadeIn
and fade in the page slowly.
I tried something like this, but it didn't work.
$("body").css("visibility", 'visible').fadeIn("slow");
Upvotes: 2
Views: 1664
Reputation: 998
$("body").hide().fadeIn("slow");
This is the easiest way to do it.
Upvotes: 0
Reputation: 69905
Instead of visibility, set the opacify to 0 and then use animate to get the best effect.
$("body").css("opacity", 0).animate({ opacity: 1}, 1000);
You can set the initial opacity to 0 through css itself which will give even better effect. With that the code is reduced to just.
$("body").animate({ opacity: 1}, 1000);
Upvotes: 7
Reputation: 23749
In your CSS, set display: none
for body.
Your JS would be $("body").fadeIn("slow");
That works!
Upvotes: 1
Reputation: 31033
initially hide the body
with css
, display:none;
$("body").hide(0).delay(2000).fadeIn("slow");
.delay
is only added for demonstration purpose
Upvotes: 0
Reputation: 78650
Change it to:
$("body").css("display", 'none').fadeIn("slow");
fadeIn
works on elements with display: none
. Also, setting visibility to visible will have it shown, not hidden.
Upvotes: 2