I have the following jquery that is triggered when a part of my page is clicked.
$('#my_link').css("color", "red").delay(500).fadeOut(500).css("color", "blue").fadeIn(500)
I can see most of the animations happening like the fadeOut and fadeIn but I never see the text turn red. I only see it turn blue. Any idea why?
Should be like this:
$('#my_link').css("color", "red").delay(500).fadeOut(500, function(){
$(this).css("color", "blue").fadeIn(500);
});
Hope this helps. Cheers
The order in which the function will be executed will be
css red --> css blue --> fadeOut --> delay --> fadeIn
http://jsfiddle.net/dXSga/
the
.delay()
method allows us to delay the execution of functions that follow it in the queue. This will not delay the no-arguments forms of.show()
or.hide()
which do not use the effects queue.
In short the .delay()
wont delay css()
which doesnt use a jQuery effect.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With