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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T09:32:18+00:00 2026-05-24T09:32:18+00:00

I have 4 form_header divs and 4 form_body divs. I’m using jQuery slideToggle() to

  • 0

I have 4 form_header divs and 4 form_body divs. I’m using jQuery slideToggle() to expand the form_body divs by clicking the form headers.

This is a perfect example of what I’m doing:
jQuery collapsible div

This is the code I’ve used:

<script type="text/javascript">
                $(document).ready(function(){

        $(".form_body").hide();

        $(".form_header").click(function(){
            $(this).next(".form_body").slideToggle(0);
        });
        });
    </script>

What I would like is when I expend one of these divs, and I expand another one the expanded one collapses, so that one can’t expand two or more of them at the same time. How can I do that? Thanks for your help.

  • 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-24T09:32:18+00:00Added an answer on May 24, 2026 at 9:32 am

    As has already been noted it may be easier to use a plugin for this, but alternatively, something like this should do the trick:

    $(".form_header").click(function() {
       $(".form_body").not($(this).next()).slideUp();
       $(this).next(".form_body").slideToggle(); 
    });
    

    It hides all the other .form_body elements, then toggles the correct one. See an example running here.

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

Sidebar

Related Questions

i have form action file in another directory but some file send to this
I have this form that pops up in a modal window like so: <?php
This is strange, but I have a web form in one of my sites
no title that fits this bug but this how it goes, i have form
I have a form set up and working nearly perfectly. I am using the
So i have a form, and onsubmit=return reg_check(this) where reg_check() is a javascript function
I have this form: in header of my website: <% form_tag request.path, :method =>
I have a form like this : <fieldset> <legend> اضافه کردن یک قالب </legend>
I have a form that calls a success message with this code: // Form
I have this very simple form: <form id=header_search><input type=text value=search></form> and this is my

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.