Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1090935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T23:26:49+00:00 2026-05-16T23:26:49+00:00

Header $(document).ready(function() { $(‘#user_box’).animate({width: 263px}, slow); $(‘#submit’).click(function(){ $(‘#user_box’).animate({width: 0px}, slow); }); }); Content <div

  • 0

Header

    $(document).ready(function() {
        $('#user_box').animate({width: "263px"}, "slow");

        $('#submit').click(function(){
            $('#user_box').animate({width: "0px"}, "slow");
        });
    });

Content

            <div id="user_box">
                <form name="login_form" id="login_form" method="post" action="index.php">
                    Username:<br />
                    <input type="text" name="username"><br />
                    <input type="submit" value="Submit" id="submit" />
                </form>
            </div>

As you can see, I’ve made it do when submit is clicked, the user_box animates back to 0pxs (slides right). Problem is I need to delay the page load by about 1 second to give the animation time to finish. But only when the Submit button is clicked. How can I delay the page to allow the animation to finish?

I’ve tried..

        $('#submit').delay(3500, function(){
            window.location = toLoad;
        });

with no joy. Any help would be greatly appreciated. Thank you.

p.s. The general idea is the user_box slides right with each query and return left with result. It’ll be mainly PHP, hence the on page load it slide right to left. I’ll wangle something later to stop it happening when logged in or something.

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T23:26:49+00:00Added an answer on May 16, 2026 at 11:26 pm

    The most reliable and flexible way to do this is to use the complete callback option on the $().animate call:

    $('#btn_submit').click(function(e){
        $submit = $(this);
    
        e.preventDefault(); // prevent the form from being submitted until we say so
    
        $('#user_box').animate(
            { width: "0px" },
            {
                duration: "slow",
                complete: function(){ //callback when animation is complete
                    $submit.parents('form').submit();
                }
            }
        );
    });
    

    Note that I’ve changed the id of the submit button. You should not give form elements the name of form properties.

    See the jQuery $().animate() API for more options: http://api.jquery.com/animate/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following jquery code: $(document).ready(function() { $(body[class*=page-calendar-practices] #content-header h1#title).after(<div id='athletics_practice-schedule'><div id='inner-title'><a href='www.example.com'
CODE: $(document).ready(function() { $('.toggle').hide(); $('.show').click(function(){ $('.toggle').toggle('slow'); $(this).attr('src','images/checkmark2.jpg'); },function(){ $('.toggle').toggle('slow'); $(this).attr('src', 'images/checkmark1.jpg'); return false; });
I have the following: in header: <script type=text/JavaScript> $(document).ready(function() { $(.modal).fancybox({ // for modals
If I have markdown like this: # A Header ``` javascript $(document).ready(function() {}) ```
Source file has: header('Content-type: text/html; charset=iso8859-1'); Source ajax (jQuery) script is: $(document).ready(function() { $.ajaxSetup({
I'm about to make a function on jQuery like this: $(document).ready(function() { $('#header_rules').click(function() {
I'm using the following code to load in content: <script type=text/javascript> jQuery.noConflict(); jQuery(document).ready(function(){ jQuery('.content-div').load(all-events.html);
I have this code $(document).ready(function(){ // ... $('form').submit(function() { // ... $.ajax({ type: GET,
My header code: $(document).ready(function() { $('#sampleFile').uploadify({ 'uploader': 'include/uploadify/uploadify.swf', 'script': 'add_list.php', 'scriptData': {'mode': 'upload'}, 'fileDataName':
Header script section. $(document).ready(function(){ var show_link = '/hr/resitration'; // That is current url. var

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.