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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T00:03:05+00:00 2026-05-31T00:03:05+00:00

I have some thumbnails that slideToggle a hidden div. I only want one to

  • 0

I have some thumbnails that slideToggle a hidden div. I only want one to stay open at once though. So when the next thumbnail is clicked, the open div closes and then the new one opens.

I was doing this with show and hide, but it looks bad because I loose the animation from slideToggle.

So what’s the best way to hide all toggled divs and then open the new one?

Here is my HTML:

<div id="mainContainer">
  <div id="rowOne">
  <img src="IllinoisLottery_Thumbnail_Taller.jpg" id="rowOneLeftImage" />
  <img src="IllinoisLottery_Thumbnail_Taller.jpg" id="rowOneMiddleImage" />
  <img src="IllinoisLottery_Thumbnail_Taller.jpg" id="rowOneRightImage"/>
  </div>

  <div id="rowOneLeftImageHidden">
      This is information for the left image in the first row.
  </div>

  <div id="rowOneMiddleImageHidden">
      This is information for the middle image in the first row.
  </div> 

   <div id="rowOneRightImageHidden">
      This is information for the right image in the first row.
  </div>

and the Jquery to Toggle (But multiple divs can be opened with this…):

$('#rowOneLeftImage').click(function(){
        $("#rowOneLeftImageHidden").slideToggle();
    });
    $('#rowOneMiddleImage').click(function(){
        $("#rowOneMiddleImageHidden").slideToggle();
    });
    $('#rowOneRightImage').click(function(){
        $("#rowOneRightImageHidden").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-31T00:03:07+00:00Added an answer on May 31, 2026 at 12:03 am

    Put a class on all the expandable divs, say, expandable.

    <div id="rowOneLeftImageHidden" class="expandable">
      This is information for the left image in the first row.
    </div>
    
    <div id="rowOneMiddleImageHidden" class="expandable">
      This is information for the middle image in the first row.
    </div> 
    
    <div id="rowOneRightImageHidden" class="expandable">
      This is information for the right image in the first row.
    </div>
    

    You can collapse all of them by referencing the class now, and using slideUp() and slideDown().

    $('#rowOneLeftImage').click(function(){
        $(".expandable").slideUp();
        $("#rowOneLeftImageHidden").slideDown();
    });
    $('#rowOneMiddleImage').click(function(){
        $(".expandable").slideUp();
        $("#rowOneMiddleImageHidden").slideDown();
    });
    $('#rowOneRightImage').click(function(){
        $(".expandable").slideUp();
        $("#rowOneRightImageHidden").slideDown();
    

    You could probably avoid all this duplicate code with a little creative use of data- elements, like having the images include a data-target element with the id the div you want them to expand, then you wouldn’t need to write n functions for n images.

    To wait until they close before opening you can use a delay, or you can do

    $(".expandable").slideUp(function () {
        // this is called once the animation completes
        if ($(this).is("#rowOneLeftImageHidden")) {
            $(this).slideDown();
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I display some objects that have thumbnails in two ways: one in a DataGridView,
I have some thumbnails with gps info that I want to pass to a
I have some thumbnails that I display with a Repeater, using a hyperlink and
I'm effectively trying to have the FlexSlider be hidden, except for some controlling thumbnails.
Need some help, please. I have a line of horizontal thumbnails loaded as ONE
I have some server code that is generating thumbnails when an image is uploaded.
I have some images I want to show in thumbnails, and I want them
I have a container div that contains some img tags. When I click on
My Thumbnails should have some shadows, I'd like to do this with some absolutely
I have some UI in VB 2005 that looks great in XP Style, but

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.