I need to run 3 jquery actions one after the other every 20 seconds.
I need to to:
- first
fadeOut()#recent - then when that has finished
click().next - then
fadeIn#recent()again
Not sure it it makes any difference but .next is a child of #recent.
This is what I have so far:
$('#recent').fadeOut();
$('#recent .next').click();
$('#recent').fadeIn();
The problem is the click triggers before the fadeOut() has finished.
Thanks
C
The issue is that
clickfires the simulated event as soon as it is invoked because it is not part of the animation event queue.The easy was is to use the [on completed] callback for
fadeOut:Note that the
fadeInanimation is registered on the animation queue and thus “works as expected”, even when not in the callback.Happy coding.