Reputation: 18198
In jQuery can you do something after you press a button and the timer starts to go from 3 seconds down to 0?
Like you have a button. You press it. 3 Seconds go by and bam.. an event fires.
Upvotes: 1
Views: 273
Reputation: 16314
You can use the .delay()
-function.
They have a nice example in the documentation about this, which fits exactly to your question.
$("button").click(function() {
$("yourelement").delay(3000).fadeIn(400);
});
Upvotes: 1
Reputation: 14051
The delay()
function (doc) :
Description: Set a timer to delay execution of subsequent items in the queue.
For your example:
$("button").click(function() {
$("[element]").delay(3000).fadeOut("slow");
});
Upvotes: 6