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
- Category: JQuery Questions
Adam
Posted 9 months ago
Either use a plugin, as suggested, or use standard javascript functions to achieve the same:
$(“p.done”).hide().fadeIn(’10000′);
window.setTimeout(function()
{
$(“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.
Other Questions
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
Adam
Posted 9 months ago
Either use a plugin, as suggested, or use standard javascript functions to achieve the same:
$(“p.done”).hide().fadeIn(’10000′);
window.setTimeout(function()
{
$(“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.
Other Questions
Login
Search
Recent Comments
- dgdg_dasdad on How does JQUERY DIFFER FROM JAVASCRIPT ? WHAT IS ITJQUERY ?
- Anas Imtiaz on How does JQUERY DIFFER FROM JAVASCRIPT ? WHAT IS ITJQUERY ?
- David D on How does JQUERY DIFFER FROM JAVASCRIPT ? WHAT IS ITJQUERY ?
- Wolfman on How does JQUERY DIFFER FROM JAVASCRIPT ? WHAT IS ITJQUERY ?
- TnT on Having a Jquery PHP problem?


Nut Bustington7
Posted 9 months ago
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′);
});
});