Link to home
Start Free TrialLog in
Avatar of dextermorgan
dextermorgan

asked on

Submit after animation is complete

I have this bit of Jquery - when the submit button is clicked, the form scrolls up and the form is submitted, but the animation does not complete before the form is submited - and page refreshed. I want the animation to complete before the form is submitted.

Thanks
$('#Register_submit').click(function() {
                $('#second-form').slideUp(800);
            });

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Gurvinder Pal Singh
Gurvinder Pal Singh
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of SleepinDevil
SleepinDevil

Do something like this. Note how I have used a type="button" instead of type="submit"
<div id="theFormDiv">
<form id="theForm" action="index.php" method="post">
<button id="Register_submit" type="button" value="Submit">
</form>
</div>

<script type="text/javascript">
$('#Register_submit').click(function() { 
       $('#theFormDiv').slideUp(800, function(){
            $("#theForm").submit();
      }); 
});
</script>

Open in new window