jQuery – Appear for set time.?

13th of April 2014 1

jQuery – Appear for set time.?

Hello. For a web application I creating, when an operation is successful a fade in message will apear using a .p class called “done” in my custom.js file the following javascript applies to it, to make it work:

$ (“p.done”).hide().fadeIn(’10000′);

I would like to change this so that instead, the message will fade in, stay for so long, for example: 10 seconds and then fade back out.
Could anyone explain to me how I would code this, or if it’s even possible.
Thank you in advance for any answers.

Karl Roberts 16 – UK

Best answer:

Answer by Nut Bustington7
You need a timer, I’ve used this one in the past with no complaints: http://jquery.offput.ca/every/ Save the file they’re offering and import it into your HTML document like you did the Jquery library.

Then you should be able to do something like:
(“p.done”).click(function () {
$ (this).show().fadeIn(’10000′);
$ (this).oneTime(“10000″, function() {
$ (this).hide().fadeOut(’10000′);

What do you think? Answer below!

Filed under § jquery plugins — Tagged with , ,

Share it!

Was it good for you to?


Support for the site!

No sponsors at the moment.

1 great comment(s) for this post

  1. Adam 2:10 am 13/04 of 2014

    Either use a plugin, as suggested, or use standard javascript functions to achieve the same:

    $ (“p.done”).hide().fadeIn(’10000′);
    $ (“p.done”).fadeOut(’2000′).hide();
    }, 10000);

    setTimeout takes two arguments: the first is the function you wish to call, and the second is how many milliseconds until you call the function. In this example, it will fade the paragraph in, taking ten seconds, wait a further ten seconds, and then fade the paragraph out over two seconds.


Your opinion matters. Add it below.

Tip: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Recent comments


Copyright jqueryui.info since 2010. All rights reserved. Design and the Absolute Theme by Tommie Hansen.