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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T03:08:32+00:00 2026-05-14T03:08:32+00:00

Page has menu items that would replace a ‘div id=foo_(current menu item)’ with ‘div

  • 0

Page has menu items that would replace a ‘div id=foo_(current menu item)’ with ‘div id=foo_(selected menu item)’ in ‘div class=foo’

Here’s what I’ve got, and try to keep your breakfast down…

    $('#t1').click(function() {
        $('#attorney').show();
        $('#insurance,#financial,#estate,#trust,#death').hide();
    });

    $('#t2').click(function() {
        $('#insurance').show();
        $('#attorney,#financial,#estate,#trust,#death').hide();
    });

    $('#t3').click(function() {
        $('#financial').show();
        $('#attorney,#insurance,#estate,#trust,#death').hide();
    });

    $('#t4').click(function() {
        $('#estate').show();
        $('#attorney,#insurance,#financial,#trust,#death').hide();
    });

    $('#t5').click(function() {
        $('#trust').show();
        $('#attorney,#insurance,#financial,#estate,#death').hide();
    });

    $('#t6').click(function() {
        $('#death').show();
        $('#attorney,#insurance,#financial,#estate,#trust').hide();
    });
  • 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-14T03:08:32+00:00Added an answer on May 14, 2026 at 3:08 am

    Switch statements are kind-of ugly.

    var things = ['attorney', 'estate', 'insurance', 'financial', 'trust', 'death'];
    var guide = {
      t1: 'attorney', t2: 'estate', t3: 'insurance', t4: 'financial', t5: 'trust', t6: 'death'
    };
    
    $('#t1, #t2, #t3, #t4, #t5, #t6').click(function() {
      var clicked = $(this).attr('id');
      $.each(things, function(_, thing) {
        var $thing = $('#' + thing);
        if (guide[clicked] == thing) $thing.show(); else $thing.hide();
      });
    });
    

    You might also consider setting up the event handler with live() instead of directly on the “t” thingies, whatever they are. It would also be neater if all the “things” (attorney, etc) could be given a class name, because then you could just hide them all quickly in the click handler with

       $('.thingClass').hide();
    

    and then just make the one visible that’s appropriate for the tab that was clicked. Then it could look something like this:

    var guide = {
      t1: 'attorney', t2: 'estate', t3: 'insurance', t4: 'financial', t5: 'trust', t6: 'death'
    };
    $('#t1, #t2, #t3, #t4, #t5, #t6').click(function() {
      $('.thingClass').hide();
      $('#' + guide[$(this).attr('id')]).show();
    });
    

    Finally, you might consider letting one of the available jQuery tab plugins handle this whole thing for you 🙂

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

Sidebar

Related Questions

I am creating a jQuery Mobile page that has two select menu's, one is
I'm making a menu that follows down the page, and has an 85% transparency.
The page has a container div which holds multiple content divs. Each content div
my Page has many hover images, sometimes there are backgrounds from div-elements or src
My page has about 25 radio button groups. When a radio button is selected
My page has 3 divs that are located horizontally. I need to make the
In my toplevel menu items, I would like to make a subline for each
I have a menu on the left of my page that is made of
I am trying to put together a page that has a header that spans
I have a page with several multiselect drop-down menus. Each menu has a general

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.