Create a delay between running functions

Possible duplicate:
jQuery delay between animations

I created two functions: one that animates an object from point A to point B, and the second that animates from point B to C. I would like to have a time delay between the two functions. Can someone please tell me how to achieve this. My unsuccessful attempt:

movt_1().delay(5000).movt_2();

Also, I would like to have a delay at the start before the first animation starts

Thank!

+3
source share
3 answers
function movt_1 ()
{
  //your code here
  setTimeout (movt_2, 5000);
}

function movt_2 ()
{
  //your code here
}

setTimeout (movt_1, 5000);

EDIT: changed the first parameter to "correct".

+2
source

jQuery.delay() , . , docs, .show() .hide() . , , setTimeout() javascript.

+3

The jQuery.delay () function only works with animation queue elements.

The example below uses .delay () and a callback function to change the second element:

$('#test1').hide('fade', {}, 1000).delay(3000).hide(0, function() {
    $('#test2').show(0).delay(3000).hide();
});
+1
source

All Articles