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 6363441
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T00:02:21+00:00 2026-05-25T00:02:21+00:00

I have a simple accordion menu I’ve put together today using the jQuery slideDown()

  • 0

I have a simple accordion menu I’ve put together today using the jQuery slideDown() and slideUp() methods.
Example code:

<h1>the header</h1>
<div class='thechild'>
the content
</div>

$(function(){

    $('h1').click(function(){
        var next = $(this).next();
        if (next.is(':visible'))
        {
            next.stop().slideUp();
        }
        else
        {
            next.stop().slideDown();
        }             
        return false;
    });

});

This works great, however if you click on one of the <h1>‘s once then again before the animation completes, you can break the slideUp() or slideDown() event.
What appears to happen is that the second time you click, it will slideUp() to zero height fine but if you are sliding down, it will only slide down to its last previous maximum height – i.e the height .thechild was at the last time you interrupted the animation by clicking.

What I need is for one click to slideUp or slideDown .thechild as appropriate, and a second click to stop the animation (if running) and slide .thechild up. A subsequent third click should slideDown .thechild to it’s full height, not the height it was at when interrupted at click #2. Hope that all makes sense 🙂

I’m sure I once had this problem before and solved it somehow, but can’t remember (or google) the solution I came up with. Is this just a limitation of those slide methods, and is the workaround to do my own animate() calls with some more working out for heights?

I’ve tried playing around with the various booleans you can pass into .stop(), but to no avail. There must be something simple I’m missing, can anyone enlighten me?

jsfiddle here: http://jsfiddle.net/cY6kX/

to recreate, double-click on the <h1> a bunch of times and watch what happens, then click a few more times to see how it will break like this until you reload the page.

Any pointers greatly appreciated

  • 1 1 Answer
  • 0 Views
  • 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-25T00:02:22+00:00Added an answer on May 25, 2026 at 12:02 am

    Add true, true to the stops to complete the animation in full:

    $(function(){
    
        $('h1').click(function(){
            var next = $(this).next();
            if (next.is(':visible'))
            {
                next.stop(true, true).slideUp();
            }
            else
            {
                next.stop(true, true).slideDown();
            }             
            return false;
        });
    
    });
    

    Fiddle: http://jsfiddle.net/maniator/cY6kX/2/

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

Sidebar

Related Questions

I have a simple accordion menu working using jQuery but I'm having trouble styling
I have made a simple accordion for my site using jQuery... It worked great,
I have a simple menu on a web page, based on the jQuery Accordion.
Hi i have a simple accordion set up with jQuery with the HTML structure
I am new to Jquery but have written a simple vertical accordion. It seems
I have a simple accordion type page containing a list of H3 headers and
i have simple regular expression: ^123$ Matches are for example 123 1234 etc. How
I have simple HTML code with some JavaScript. It looks like: <html> <head> <script
I have the following jquery that I wrote: $(document).ready(function(){ $('div.contentTxtBox#home').addClass('current').show(); $('a.menu').click(function() { $('div.contentTxtBox.current').hide(slide, {
I have a very simple accordion in my webpage that I initialise with :

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.