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

  • Home
  • SEARCH
  • 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 6881963
In Process

The Archive Base Latest Questions

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

What i want is hide all content first, then click one tab, the corresponding

  • 0

What i want is hide all content first, then click one tab, the corresponding content shows (the tab becomes ‘active’), where click it again it will disappear. some of the tabs are just a ‘mailto’ link.

problem is i can’t hide the tabs when click again

    $(document).ready(function(){
    $('#nav div').hide();
    $('#nav div:first').show();
    $('#nav ul li:first').addClass('active');
    $('#nav ul li a').click(function(){ 
        $('#nav div').hide();
        $('#nav ul li').removeClass('active');
        $(this).parent().addClass('active'); 
        var currentTab = $(this).attr('href'); 
        if($(currentTab).css('display')=='none'){
            $(currentTab).show();
        }else{
            $(currentTab).hide();
        }

    }
);
});

the navigation code is the following:

<div id="nav">
    <ul>
      <li><a href="#about">About</a></li>
      <li><a href="mailto:email">Email</a></li>
      <li><a href="#contact">Contact</a></li>
    </ul>
    <div id="about">
      about
    </div>
    <div id="contact">
      contact
    </div>
</div>
  • 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-27T05:11:43+00:00Added an answer on May 27, 2026 at 5:11 am

    This should work:

    $(function() {
        $('#nav div').hide();
        $('#nav div:first').show();
        $('#nav ul li:first').addClass('active');
        $('#nav ul li a').click(function(){
            var currentTab = $(this).attr('href');
            var vis = $(currentTab).is(':visible');
            $('#nav div').hide();
            $('#nav ul li').removeClass('active');
            $(this).parent().addClass('active');
            if(vis) {
                $(currentTab).hide();
            } else {
                $(currentTab).show();
            }
        });
    });
    

    you have to check if the current tab is visible before you hide it.

    working: http://jsfiddle.net/tqhHA/

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

Sidebar

Related Questions

I have this $(document).ready(function() { //Default Action $(.tab_content).hide(); //Hide all content $(ul.tabs li:first).addClass(active).show(); //Activate
I want to hide all mysql error messages without using mysql_error() . Are there
I want to hide all the descendents of the ul for my tree menu
i have the following html , and i want to hide all lsHeader which
I want to hide these fieldsets in a Drupal 6 site for some content
I want only one drawer to be open at startup. At the moment, all
I am using the jquery Masonry plugin and looking to hide all content until
For example, I want all the elements with an ID hide_ + a value.
I want to hide the selected item from the opened WPF combo box, basically
I want to hide the Next button on my ASP.NET Wizard control using JavaScript.

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.