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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T15:58:42+00:00 2026-05-27T15:58:42+00:00

so I got 4 div tags, with id’s – content1 ; content2 ; content3

  • 0

so I got 4 div tags, with id’s – content1; content2; content3 and content4.
at start, content1 is only shown, and all other 3 contents are invisible, and I got menu with links, #content1, #content2, #content3, #content4.
So I need to create, when somebody clicks for example on content3 link, current content will hide and content3 content will show up, same to all other contents.

My question – I know how to make show/hide with one element, but I haven’t created anything with 2 or more elements, so maybe you could help me create it?

  • 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-27T15:58:43+00:00Added an answer on May 27, 2026 at 3:58 pm

    If you give your content divs a class, say “content”, it is easy to select them as a group and hide them. Similarly, if you give your menu links a class you can assign a click handler to all of them at once. So:

    <a class="menu" href="#content1">Content 1</a>
    <div class="content" id="content1">Some content here</div>
    <!-- and so forth for your other links and divs -->
    
    <script>
       $(function() {
           $("a.menu").click(function() {
              $("div.content").hide();
              $(this.href).show();
              return false;
           });
       });
    </script>
    

    Note that you don’t really need to wrap the code in a document.ready handler if the script block appears after the elements in question, but I’ve done so here for completeness.

    I realise the above may not correspond to your html markup, but since you didn’t actually provide your html markup I had to guess…

    If there’s anything in this answer that you don’t understand I suggest you read through some jQuery tutorials, such as this one from the jQuery website; a tutorial is beyond the scope of a StackOverflow answer…

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

Sidebar

Related Questions

Say I got a few DIV tags in a HTML page like: <DIV ID=all>
I've got a div that uses overflow:auto to keep the contents inside the div
Hi I've got a DIV section that has only its title visible initially. What
I have got a div [projItemsContent] that varies in height based on the contents,the
I've got a bunch of buttons nested within div tags in my html <div
Basically I've got two anchor tags separated by a div. <a class=foo></a> <div class=count>0</a>
I've got a div that looks like this: <div id=exampleDiv class=class1 class2 title=example title></div>
I've got several div id's, each containing a different client. I want to be
Here's my scenario: I've got a div on Page A. When an event happens
I've got a popup div showing on rightclick (I know this breaks expected functionality

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.