I want to delay things like the css from happening but this method wont work. Any ideas on how I can delay tasks.
$(function() {
$('.btn').click(function() {
$('.divOne').animate({"left": "+=400px"}, "fast").delay(800).css("background-color","yellow");
});
});
You can use
.queue()to stick it on the default animation (fx) queue, like this:You can test it here, all this does is stick it in the
fxqueue using.queue(function(n)), thenis the next function in the queue, so we’re calling it, for example if you didn’t do this and added any animation after it, it just wouldn’t run, because the next function or.dequeue()isn’t called.