> I have made a mailform and if the user click on the submit button the > mailform should first dissapear before post the message. I had tried > the follow way: > > $("form").submit(function () { > > if ($("#div1").is(":visible")) { > $("#div1").animate({ > height:'hide', > opacity:'hide' > },"slow","easeInOutCirc"); > > }; > > }); > > But the effect could not work because the form is post the message > promptly. There has to be a timeout or something like this but I don´t > know how...:-(
This should work: $("form").submit(function () { var form = this; if ($("#div1").is(":visible")) { $("#div1").animate({ height: 'hide', opacity:'hide' }, "slow", "easeInOutCirc", function() { // submit the form manually in animate callback form.submit(); }); return false; // <-- important } });