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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T05:02:35+00:00 2026-06-01T05:02:35+00:00

What is the best way to hide all links except for one in javascript?

  • 0

What is the best way to hide all links except for one in javascript? (jquery is okay)

Say I have the following:

<div id="choices"> 
  <div><a href="#">A<></div> 
  <div><a href="#">B</a></div> 
  <div><a href="#">C</a></div> 
</div>

I want to make it such that if a user clicks link A, B, or C, the div’s that do not contain the one that was selected disappear and the choice selected pops up in an alert box. Upon clicking on a reset button, all the divs appear again as normal.

Example: User clicks A, results in B and C divs hiding. User kicks Reset button and all show up again.

How do I accomplish this?

NOTE: I have been assigning IDs to each of the A, B, C divs respectively and made a function where when the user clicks B, it calls a $(divnotclicked).hide() for the ones I want to hide. And for the reset button I just do .show() for each of them $(A).show(), $(b) $.show()(C).show()…. but theres gotta be a way to do with without me assigning IDs to each of them. Im looking for the best way to do it.

Im looking for the best way to do this, preferably without manually calling functions for each of them or assigning IDs to each div within the “choices” div. Or having to call on each individual div to “.show” upon clicking the Reset button.

  • 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-01T05:02:36+00:00Added an answer on June 1, 2026 at 5:02 am

    With jQuery, it’s quite simple:

    $('#choices div').click(function() { $(this).siblings().hide(); });
    $('#resetButton').click(function() { $('#choices div').show(); });
    

    Also, here is a jsFiddle with this code in action. In general, jsFiddle is an excelent tool when you need to play with jQuery (or other frameworks, for that matter).

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

Sidebar

Related Questions

What is the best way to authorize all users to one single page in
What is the best way to hide inline Javascript and CSS from downlevel browsers?
Using jquery, what is the best way to delete all divs with a certain
What is the best way to hide Tab headers when there is only a
Bascially I want to know the best way to hide/show an ASP.NET control from
The best way of describing this is I have a table of people with
I just realized that there is no best way to hide MySQL string connection
I have a show/hide Jquery function in place on a multi-entry page which toggles
I have some thumbnails that slideToggle a hidden div. I only want one to
I have 2 divs in ma page. I want to show one and hide

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.