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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:07:51+00:00 2026-06-16T00:07:51+00:00

I know the show/hide thing has been covered to death on stack, but I

  • 0

I know the show/hide thing has been covered to death on stack, but I just can’t find a solution that works for me, sorry. I’ve tried several JS/jQuery solutions that I found and can’t quite get one to behave the way I’d like.

I have many divs that are very similar in content (content changes slightly based on version selected), and all have the exact same style.

Desired behavior

I’d like one div to show by default with all others hidden. Then, based on a link click, a different version div is displayed and all other content divs are hidden.

Basic HTML

<div class="container">
  <h1>Header</h1>
  <p>Basic info about page</p>
  <ul>
    <li><a href="#ver1" id="linkToVer1">Version 1</a></li>
    <li><a href="#ver2" id="linkToVer2">Version 2</a></li>
    // More links to other divs
  </ul>

  <div class="content" id="ver1">    // I'd like this div to be the default
     Content here                    // when the page loads. All other divs 
  </div>                             // are hidden until a link is clicked.

  <div class="content" id="ver2">
     Content here
  </div>

  // More content divs
</div>

I’ll have up to a dozen different versions of these content divs.

JS or jQuery is fine, but jQuery is preferred because I’ll probably add some kind of show/hide effect. I don’t care that greatly about the naming structure of the divs or links.

  • 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-16T00:07:52+00:00Added an answer on June 16, 2026 at 12:07 am
    $("div.containter ul li").each(function(){
        $(this).onclick(function(){
    
           $("div.content").hide();
    
          $("div" + $(this).attr("href")).show();
    
        });
    });
    

    Wrap that in a $(document).ready or whereever and you should be good to go my friend. Learn the code, so that in the future, you are gosu.

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

Sidebar

Related Questions

I know that the following code should show and hide a tiny circular progress
I know that you can show current GPS moving location on map with WP7
I know of several approaches using a macro (VBA) to show/hide columns and rows
I know the how to show th image on jsp file. But never thought
I would like to know how I can show the output from this piece
I know I can use the -n flag in git grep to show the
I want to show and hide a label and its control. I can do
Is there a way to toggle show/hide for data that is dynamically populated in
I'm hoping that someone else has experienced this and can point me in the
Wrote an exercise & solution page, with buttons that start js functions that show

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.