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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T12:16:11+00:00 2026-05-25T12:16:11+00:00

I have about 20 buttons on a page. I have set them up with

  • 0

I have about 20 buttons on a page. I have set them up with jquery to slide toggle to show and hide a div. It works well but only if the same button is used to close the div before selecting a new div. I want that if a button is clicked it will slide up open divs, before it slides down its own div. Right now if a div is still showing, and a different button is clicked, the open div wont close.

I think there are too many buttons to make an if function to test each div by name if open, and then slide up. is there a general slide up all open divs?

If I add a class and use css to display:block, I dont get animation, so I am using slidetoggle. I am happy to redo my code if there is a better way? Is there a way to close the open divs?

$(document).ready(function(){
  $('.show1').click(function(){
    $(".row1").slideToggle();
  });

  $('.show2').click(function(){
    $(".row2").slideToggle();
  });

  $('.show3').click(function(){
   $(".row3").slideToggle();
  });
});
  • 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-25T12:16:12+00:00Added an answer on May 25, 2026 at 12:16 pm

    The easiest way I see is to add a class (like row) to all your div and to hide them using
    $(".row").not(".rowX").slideUp(); The not rowX is there to keep the toggle alive (and with that update, order doesn’t matter ;)).

    That’ll end up like:

    $('.show3').click(function(){
       $(".row").not(".row3").slideUp();
       $(".row3").slideToggle();
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have about 20 grid views that I have to create. All of them
I have the following HTML: <div id=dynamicRadioButtons> </div> Using jQuery I'd like to append
Currently I have a set of fields on a page. When the button is
I don't know anything about cookies or how to set them and I need
I have three buttons on my main page. Something weird happens when I try
I have a simple ASP.net page where users can edit information about themselves. When
I have like buttons on about 8 pages on my site. I have a
I have an HTML5 page with several data inputs inside a jQuery Dialog box.
I have a list view that show a list of items...well not all of
I have a like/send button that I've set up on a customer's home page.

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.