In your case, you can use arunes solution using callback from animation. However, if you need to add a delay between the animation and the callback that is running, you can do this too, as in:
$('.container').fadeIn(function () { $(this).delay(2000).queue(function () { alert('Custom function executed two seconds after fadeIn()!'); $(this).dequeue(); }); });
source share