Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delay jquery animation?

I can't seem to delay the showing of a div. I want to delay the animation by about 20 seconds is this possible???

$("#microcharcounter").delay(10000).show();
like image 602
user342391 Avatar asked Aug 27 '10 12:08

user342391


People also ask

How to call function with delay in jQuery?

To call a jQuery function after a certain delay, use the siteTimeout() method. Here, jQuery fadeOut() function is called after some seconds.

How do you delay a function?

To delay a function call, use setTimeout() function. functionname − The function name for the function to be executed. milliseconds − The number of milliseconds. arg1, arg2, arg3 − These are the arguments passed to the function.


1 Answers

Try this:

$("#microcharcounter").delay(10000).show(0);

or this:

$("#microcharcounter").delay(10000).queue(function(n) {
    $(this).show();
    n();
});

The reason for this is that .delay() will only delay items in an animation queue. So you can make .show() a short animation by adding a duration of '0', or add it to the queue with .queue().

like image 146
user113716 Avatar answered Sep 29 '22 10:09

user113716