Take the 2-minute tour ×
Code Review Stack Exchange is a question and answer site for peer programmer code reviews. It's 100% free, no registration required.

I am new to web developtment and I want to Fadein a div using jquery. I used the following jquery code to fadein my div. It is not working, what am I doing wrong?

html

<body>
    <div id="foo">
      <p>Hello, World!</p>
    </div>
    <script type="text/javascript" src="js/script.js"></script>
</body>​

javascript

$(document).ready(function() 
{ $('#foo').fadeIn(3000);
 });​
share|improve this question
add comment

closed as off-topic by Brian Reichle, Uri Agassi, Marc-Andre, rolfl, syb0rg Feb 27 at 21:47

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Your question must contain working code for us to review it here. For questions regarding specific problems encountered while coding, try Stack Overflow. After getting your code to work, you may edit this question seeking a review of your working code." – Uri Agassi, Marc-Andre, rolfl, syb0rg
If this question can be reworded to fit the rules in the help center, please edit the question.

1 Answer

up vote 1 down vote accepted

Well if you didn't set the original CSS style on your element to an opacity less than 1.0 then there's nothing to fade IN to. It's already IN so to speak, meaning it's already fully visible.

Also, I believe fadeIn requires a callback as the second parameter.

$(document).ready(function() { 
    $('#foo').fadeIn(3000, function() {
        // Animation complete
    });
});​
share|improve this answer
1  
Thanks, that is true, or I could also use display: none; in css –  Conrad C Dec 17 '12 at 4:37
2  
@Xaxis The callback parameter is optional. –  RoToRa Dec 17 '12 at 11:59
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.