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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T14:22:20+00:00 2026-05-26T14:22:20+00:00

I want to slidetoggle divs with different content in it by targeting the content

  • 0

I want to slidetoggle divs with different content in it by targeting the content by name in my navigation.

I have this already:

$(".div1, .div2, .div3").hide();

$(document).ready(function(){

    $("nav a").click(function () {  
    var divname= this.name;
    $("."+divname).siblings().slideUp(500, function () {
    $("."+divname).slideToggle();
});
});
});

<nav>
<a name="div1">SlideToggle Div 1</a>
<a name="div2">SlideToggle Div 2</a>
<a name="div3">SlideToggle Div 2</a>
</nav>

<div id="container">
<div class="div1">Content Div 1</div>
<div class="div2">Content Div 2</div>
<div class="div3">Content Div 3</div>
</div>

I want that every div slides up first, then slidesdown with the content of the new div, that is targeted in menue and so forth.

Problem with that script:

With two divs it’s working. Adding a third does make it slide down and slide up. Adding a forth does make it slide down, slide up and slide down and so forth. Must be something wrong with the siblings idea?

Thank you.

  • 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-26T14:22:21+00:00Added an answer on May 26, 2026 at 2:22 pm

    Have a working jsfiddle page so look at this. I did some work on your code check out if this is what you wanted. UPDATED THE CODE Retry the link now.

    $(".div1, .div2, .div3").hide();
    $(document).ready(function() {
      var firstTime = true;
      $("nav a").click(function() {
        var divname = this.name;
        if (!firstTime) {
            if ($(".slid").hasClass(divname)) {
                firstTime = true;
                $(".slid").removeClass("slid").slideUp();
            } else {
    
                $(".slid").removeClass('slid').slideUp(500, function() {
                    $("." + divname).slideToggle().addClass("slid");
    
                });
            }
        } else {
            $("." + divname).slideDown().addClass("slid");
            firstTime = false;
        }
    
      });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

$(#clickme).click( function(){ $(this).slideToggle(1000); $(this).load(MYTEXT.txt); $(this).slideToggle(1000); } ) I want the new content of my
I have a problem with jQuery selectors: $(ul.questions li).not(.title, .content).click().live('click', function(){ $(.inspector).slideToggle(); if($(this).hasClass(selected)) {
I have a contact form that can be hidden using .slideToggle() but I want
I have a function where I want the speed of the slideToggle to be
I came across this great JQuery example of using a slidetoggle. I want to
I have some thumbnails that slideToggle a hidden div. I only want one to
I have a set of divs that I want to make collapsible/expandable using jQuery's
I have a div I want to hide when clicking outside it. It almost
Basically I hide all of the answer divs on the page, but I want
i have multiple divs with the same class on my page. I want to

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.