$(‘#div1’).focus(function () {
callAnotherFunction();
$(this).animate({});
}
I’m trying to make $(this).animate({}); execute after callAnotherFunction(); has completed. Currently, both run at the same time. I’ve timed to use delay(), setTimeout() to no avail too. Is there anyway this can be done?
Thanks!
JavaScript is single threaded, so only one expression will be executed at a time. In the example that you’ve given,
$(this).animate({});will not run untilcallAnotherFunction();has completed.It’s possible that
callAnotherFunction();runs additional code on a timer or delay, in which case you would have to have$(this).animate({});on a timeout with an equal or greater delay for it to execute afterwards.