Tell me more ×
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

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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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