1

Im using this to delay and fadeout some messages on my site.

<script> $("#infomsg").delay(2400).fadeOut(600);</script>

So when page is loaded the message is still on page 2400ms after that is gone with fadeout, but how i can make, when you open page i need this message to display after 3 sec. or simple slow fadein first.. im try something like this

<script> $("#infomsg").fadeIn(1200).delay(2400).fadeOut(600);</script>

and this not work for me, can you help me to make this ?

P.S Sorry for my english and thanks

3 Answers 3

2

I prefer to use callbacks.

$("#infomsg").fadeIn(1200, function() {
  $(this).delay(2400).fadeOut(600);
});

so...

  • fadeIn
  • wait for 2400 after fadeIn
  • fadeOut
Sign up to request clarification or add additional context in comments.

2 Comments

No you don't. Look at the example in the documentation: api.jquery.com/delay
@tvanfosson - correct, you can certainly chain them too. It just sounded like user994461 wanted to do additional things.
1

You should probably be running this on document load. Other than that, the only problem I see is a missing period.

<script>
   $(function() {
       $("#infomsg").fadeIn(1200)
                    .delay(2400)
                    .fadeOut(600);
    });
</script>

3 Comments

Im just try and again all works fine only fadeIn not work.. :(
@user994461 - does the element start hidden, i.e., have you set style="display: none;" on the element or used CSS to hide it initially? Or, better yet, use $('#infomsg').hide().fadeIn(1200)...
Ohh im forgot for style="display: none;" :( Thanks
0

$("#infomsg").fadeIn(1200).delay(2400).fadeOut(600); you miss a dot

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.