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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T21:03:30+00:00 2026-06-15T21:03:30+00:00

I have a script that works on one link on jsfiddle. I have two

  • 0

I have a script that works on one link on jsfiddle.

I have two links. Link one is “Link one” the other one is “Link two” you can see the code on jsfiddle = http://jsfiddle.net/lamberta/7qGEJ/4/

It works to show and hide but i cant make it show one and other. It shows everything.

If i press Link one I want to show “.open-container-One”
And if I press Link two i just want to show “open-container-Two”

Hope you understand my issue.

jsCode:

$(document).ready(function() {
    var $div = $('.test');
    var height = $div.height();
    $div.hide().css({
        height: 0
    });

    $('a').click(function() {
        if ($div.is(':visible')) {
            $div.animate({
                height: 0
            }, {
                duration: 500,
                complete: function() {
                    $div.hide();
                }
            });
        } else {
            $div.show().animate({
                height: height
            }, {
                duration: 500
            });
        }

        return false;
    });
});​
  • 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-06-15T21:03:32+00:00Added an answer on June 15, 2026 at 9:03 pm

    Although I like @adeneo’s answer, I prefer this method using selectors rather than elements :

    $(".test").hide();
    $('.list a').each(function(i) {
        $(this).on("click", function() {
            $(".test").slideUp(0).eq(i).slideDown(400, function() {
                $(".close a").on("click", function() {
                    $(".test").slideUp();
                }); // on click close
            }); // after slideDown (shown div)
        }); // on click link
    }); // each 
    

    The only condition is that there should be the same number of links (list items) as the number of div to be shown and in the same order.

    See JSFIDDLE

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

Sidebar

Related Questions

I have the following code that works fine in IE: <HTML> <BODY> <script language=JavaScript>
I have this code : http://jsfiddle.net/Qchmqs/BSKrG/ <div class=step><-- this is darned wrong <div id=step2><a>Darn</a></div>
I have a custom jQuery script that works fine in all bowsers but one
I have a rule that works for one direction but, not the other. A
I have a script that works great. It is quite complex and does numerous
I have this script that works, but I need to change the format of
With help from you guys I now have a script that works like a
I have this jQuery script that works fine: $(select).change(function () { var finalPrice =
I have the following script that works well in Firefox and Chrome (not sure
I have a script on here that works fine in FF14 and Chrome20. A

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.