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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T20:06:56+00:00 2026-06-16T20:06:56+00:00

I would appreciate some assistance with a content toggle. I currently have 2 tabs

  • 0

I would appreciate some assistance with a content toggle.

I currently have 2 tabs that toggle content – one must be set to focus at any one time and an additional class of active appended when the selected .content-drawer is visible.

Whilst my efforts below work when operating single tabs, the active state doesn’t work when switching between states as the :visible condition fires at the wrong time.

Could someone point me in the right direction? Here’s my current jsfiddle

    $('.content-drawer').hide();

    $('.tab').click(function() {
        var target = $(this.rel);
            $('.content-drawer').not(target).slideUp();
            target.delay(500).slideToggle();
            $('.tabs > li.focus').removeClass('focus');
            $(this).parent().addClass('active focus');

    if ( $('.content-drawer:visible').length ) {
       $('.tabs > li.active').removeClass('active');
    }
    return false;
});​


<ul class="tabs">
   <li class="focus">
       <a href="#" rel="#calc" class="tab"><i class="icon-plus"></i>Calculator</a>
   </li>
   <li>
       <a href="#" rel="#info" class="tab"><i class="icon-info"></i>Info</a>
    </li>
</ul>

<div class="content-drawer" id="calc">
    <p>Calc Content</p>    
</div>
<div class="content-drawer" id="info">
    <p>Info Content</p>    
</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-06-16T20:06:57+00:00Added an answer on June 16, 2026 at 8:06 pm

    Try this code

        $('.content-drawer').hide();
    
    $('.tab').click(function() {
        var $this = $(this);
        var target = $(this.rel);
        $this.closest('li').addClass('active focus');
        // Add the classes to the closest li of the clicked anchor
        $('.tab').not($this).closest('li').removeClass('active focus');
        // Remove the classes for the non-clicked items
        $('.content-drawer').not(target).slideUp();
        // Slideup the other contents
        target.delay(500).slideToggle();
        // Toggle the current content
        if (target.is(':visible')) {
            // Only if the target is visible remove the active class
            $this.closest('li').removeClass('active');
        } 
        return false;
    });​
    

    Check Fiddle

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

Sidebar

Related Questions

Would appreciate some assistance i have a txt file witht he following contents: 1234|dog|apartment|two
I would appreciate some help with something I working on and have not done
I would appreciate some help on creating the proper SQL to retrieve only one
I have a problem finding references to this subject and would appreciate some help.
I'm currently looking into using WIF for an upcoming project and would appreciate some
I've been stuck on this one for some time now and would really appreciate
I would very much appreciate some assistance from the community on replacing a string
Would very much appreciate some assistance with this issue. I use the following common
I am making use of jQuery's .autocomplete plugin, and I would appreciate some assistance
Have a problem I'm trying to work through and would very much appreciate some

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.