container.slideUp(500, function () { // code here will run once the slideUp has completed $(this).removeClass("active"); });