jQuery - Waiting for the fadeOut to complete before running fadeIn
Another option is using promise which will wait for all pending animations on .sidebarform to complete first even if they were started elsewhere:
$('.sidebarform').fadeOut('slow').promise().done(function() {
$('.sidebarsuccess').fadeIn('slow');
});
The fadeOut
function has a callback that it executes when the animation is done:
$('.sidebarform').fadeOut('slow', function() {
$('.sidebarsuccess').fadeIn('slow');
});