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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T22:34:24+00:00 2026-05-31T22:34:24+00:00

My HTML: <div class=menu> <a href=javascript:displayonediv(‘sections1’);>Energy Profile</a> <a href=javascript:displayonediv(‘sections2’);>Statistics</a> </div> <div name=sections id=sections1> ….

  • 0

My HTML:

<div class="menu">
    <a href="javascript:displayonediv('sections1');">Energy Profile</a>
    <a href="javascript:displayonediv('sections2');">Statistics</a>
</div>

<div name="sections" id="sections1">
    .... some stuff ....
</div>
<div name="sections" id="sections2">
    .... some stuff ....
</div>

My JavaScript code:

function displayonediv(choosendiv) {
    $('div[name|="sections"]').each(function(index) {
        if ($(this).attr("id") == choosendiv) {
            $(this).show(200);
        }
        else {
            $(this).hide(200);
        }
    });
}

By default, the div with id=sections1 displays when the page loads while the div with id=sections2 is hidden. In my controller after I submit a form I am redirecting to the div with id=sections2. However, I cannot seem to redirect to that page and load that specific div (id=sections2). I have tried to use anchor tags but my efforts have been in vain.

  • 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-31T22:34:26+00:00Added an answer on May 31, 2026 at 10:34 pm

    I think you should do something like this:

    Hide all the sections in CSS so that they not even visible during load:

    #sections1, #sections2 {
        display: none;
    }
    

    The CSS is optional. Use this simple function to do the dynamic show and hide:

    function displayonediv(chosendiv) {
        //Make sure all other divs are really hidden if there are subsequent calls:
        $("div[name^=sections]").hide(200);
        $("#" + chosendiv).show(200);
    }
    

    Also:

    If that doesn’t work and you are able to change that terrible HTML then change the HTML as follows.

    <div class="menu">
        <a class="section" href="#sections1">Energy Profile</a>
        <a class="section" href="#sections2">Statistics</a>
    </div>
    
    <div class="sections" id="sections1">
        .... some stuff ....
    </div>
     <div class="sections" id="sections2">
        .... some stuff ....
    </div>
    

    And have this js:

    $("a.section").click(function(event) {
        $("div.sections").hide(200);
        $($(this).attr('href')).show(200);
    });
    

    As with most things in jQuery, all your code should be $(function(){ /*here*/});.

    To make the section load when the page is loaded:

    $(function() {
        $(window.location.hash).show(200);
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Assuming I have this HTML structure: <ul class='menu'> <li> <div></div> <div> <div></div> <div> <a
My HTML Dom like the followings: <div class=menu> <input type=checkbox value=1 class=chk-act> <input type=checkbox
Here is my HTML: <li> <div class=menu_inner> <a href=#> <div class=button><img class=486 src=images/portalbutton.png /></div>
HTML <p href=products.php?ref=fijo&tipo=7001ad class=principal>Fijas</p> <div class=menu_body id=fijo> <a href=products.php?ref=fijo&tipo=7001ad>Normal (7001AD)</a> <a href=products.php?ref=fijo&tipo=7001md>Aislada (7001MD)</a> <a
html- <div class=hbg> </div> some menu items here jquery for mouser over on menu
<div class="menu_item_variant" id="date" onmouseover="mouseIn(this.id)" onmouseout="mouseOut(this.id)"> <a href="dating-advice.html">Dating Coaching &amp; Advice</a> </div> hi, could some
I'm developing a html with this structure div id=menuContainer> <div class = menu ui-accordion-header
I have a example html menu: <div class=mmenu> <ul> <li> <div class=menu_button id=m1 >A</div>
I have html structure like below: <div id=banner-menu-holder> <div> <div class=avalible> <div class=items-holder> <div>
<div class = a> <div class = a b> text </div> </div> <script> alert($(.a).html());

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.