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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T08:48:51+00:00 2026-06-03T08:48:51+00:00

when I click on any link the correspoding div shows up but when I

  • 0

when I click on any link the correspoding div shows up
but when I click the next link, the newly clicked dive shows up as well as the previously clicked. I would like the previos div to hide. NEW to development please some one help me……..

this is the html code for links:

<a class="hide" onclick="showdiv('firstimpression'); " href="#">First Impression</a>
<a class="hide" onclick="showdiv('speaking'); " href="#">Speaking</a>
<a class="hide" onclick="showdiv('eating'); " href="#">Eating</a>
<a class="hide" onclick="showdiv('taste'); " href="#">Taste</a>
<a class="hide" onclick="showdiv('saliva'); " href="#">Saliva</a>
<a class="hide" onclick="showdiv('cleaning');" href="#">Cleaning</a>
<a class="hide" onclick="showdiv('nighttime');" href="#">Night Time</a>
<a class="hide" onclick="showdiv('singledenture');" href="#">Single Denture</a>
<a class="hide" onclick="showdiv('soreness');"  href="#">Soreness</a>
<a class="hide" onclick="showdiv('burning');" href="#">Burning</a>
<a class="hide" onclick="showdiv('adapting');" href="#">Adapting</a>
<a class="hide" onclick="showdiv('futureconsideration');" href="#">Future Consideration</a>
<a class="hide" onclick="showdiv('conclusion');" href="#">Conclusion</a>

these are the divs:

<div id="firstimpression" class="patientinfodivs">
<div id="speaking" class="patientinfodivs">

…..and so on

Javascript code

<script type="text/javascript">
function showdiv(id){
document.getElementById(id).style.display = "block";
}
</script>
  • 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-03T08:48:52+00:00Added an answer on June 3, 2026 at 8:48 am

    As much as I hate creating global variables, they just come in so handy sometimes…

    var _hidediv = null;
    function showdiv(id) {
        if(_hidediv)
            _hidediv();
        var div = document.getElementById(id);
        div.style.display = 'block';
        _hidediv = function () { div.style.display = 'none'; };
    }
    

    This will prevent you from needlessly searching through divs to find the one you should hide.

    Edit: Expanding upon @StevenRoose’s suggestion:

    var _targetdiv = null;
    function showdiv(id) {
        if(_targetdiv)
            _targetdiv.style.display = 'none';
        _targetdiv = document.getElementById(id);
        _targetdiv.style.display = 'block';
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

is there any jquery or any script, that when u click on one link,
I have HTML code like this : <div> <a>Link A1</a> <a>Link A2</a> <a>Link A3</a>
Let's say I want that every time the user click any link an alert
How would I write an event in jQuery so that if I click any
I have a few links, which should toggle their corresponding div like this... $('#link
I am using AJAX/JSON combination in Zend Framework. Whenever I click any link in
I have a treeview and i want no postback on click any childnodes.And i
I just installed XCode 3.2.1. When I open the Developer Documentation and click any
i added ascx control in tab control with C# codes. if you click any
if i click on any checkbox all previous checkboxes must get checked my logic

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.