view raw
user2962388 user2962388 - 6 months ago 39
CSS Question

jQuery .fadeIn() on page load?

I'm trying to set up some code so that I have a that is hidden at first but then fades in after the page is loaded.

I have the following HTML code:

<div class="hidden">
<p>This is some text.</p>

Then I also have this CSS code, which hides the

display: none

Finally, I have my jQuery:

$(document).ready(function() {

What I was hoping would happen was that the first .fadeOut() would fade out the , the removeClass would stop the CSS from hiding it, and the final .fadeIn() would fade it back onto the page. Unfortunately, this did not work.

You can view the code here:Fiddle

So can someone please tell me how to keep a
hidden until a page loads, and then fade it in using jQuery?



The problem is fadeIn works on hidden elements, when you remove the hidden class before the fadeIn() is called the element is fully displayed so there is nothing to to fadeIn()

It should be

$(document).ready(function () {

Demo: Fiddle