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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 18, 20262026-06-18T16:38:40+00:00 2026-06-18T16:38:40+00:00

I know this topic has been asked before but looking through the posts isn’t

  • 0

I know this topic has been asked before but looking through the posts isn’t quite what I’m looking for so please bear with me for a minute.

first here’s my little jQuery (works flawlessly)

$(document).ready(function(){
    $(".tabs li").click(function() {
        $(".tab-content").hide();
        var selected_tab = $(this).find("a").attr("href");
        $(selected_tab).fadeIn();
        $(".tabs li").removeClass('current');
        $(this).addClass("current");
        return false;
    });
});

And my basic HTML

<ul class="tabs">
    <li class="active"><a href="#tab4">Tab 4</a></li>
    <li><a href="#tab5"><div class="alert-icon">Tab 5</div></a></li>
    <li><a href="#tab6"><div class="printer-icon">Tab 6</div></a></li>
</ul>

 <div id="tab4" class="tab-content">Tab 4</div>
 <div id="tab5" class="tab-content">Tab 5 </div>
 <div id="tab6" class="tab-content">Tab 6 </div>

Naturally if I put more than 1 tab section on the page, every time a tab is clicked the content of all tabs will “hide” and I need to make each tabbed section behave independently.

My problem is I want to avoid going the ID route, ideally I can put the JS right into the template and every time someone needs a tabbed area they can just paste the HTML, maybe add an ID to the UL and fill in the blanks.

Tabs and their content will be put in by other not very tetchy people so if I can avoid having them use JS, life would be wonderful!

I thought about playing with filters, string replaces, child elements (put the divs in the LIs?) etc. but before diving into an unfamiliar ocean without my ducky float I thought one of the pros here can give me a hint and point me in the right direction. js/jQuery was never my favorite ^^.

Thanks a lot!

  • 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-18T16:38:41+00:00Added an answer on June 18, 2026 at 4:38 pm

    This should do the trick : http://jsfiddle.net/BLGUW/

    HTML :

    <div class="tabs">
            <ul>
                <li class="active"><a href="#tab4">Tab 4</a></li>
            <li><a href="#tab5"><div class="alert-icon">Tab 5</div></a></li>
            <li><a href="#tab6"><div class="printer-icon">Tab 6</div></a></li>
        </ul>
        <div id="tab4" class="tab-content">Tab 4</div>
        <div id="tab5" class="tab-content">Tab 5 </div>
        <div id="tab6" class="tab-content">Tab 6 </div>
    </div>
    
    <div class="tabs">
        <ul>
        <li class="active"><a href="#tab40">Tab 4</a></li>
        <li><a href="#tab50"><div class="alert-icon">Tab 5</div></a></li>
        <li><a href="#tab60"><div class="printer-icon">Tab 6</div></a></li>
        </ul>
        <div id="tab40" class="tab-content">Tab 4</div>
        <div id="tab50" class="tab-content">Tab 5 </div>
        <div id="tab60" class="tab-content">Tab 6 </div>
    </div>
    

    JS

    $(document).ready(function(){
        $(".tabs li").click(function() {
            $(this).parent().parent().find(".tab-content").hide();
            var selected_tab = $(this).find("a").attr("href");
            $(selected_tab).fadeIn();
            $(this).parent().find("li").removeClass('current');
            $(this).addClass("current");
            return false;
        });
    });
    

    I’m sure this can be optimized 😉

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

Sidebar

Related Questions

I know this topic has been asked, but the posts are all out of
I know that this topic has been asked several times before but none of
I realize this isn't a new topic and that it has been asked before.
I know this has been asked before, but I'm struggling to get this working
I know a similar question on this topic has been asked, but doesn't look
I know this topic has been approached several times before in various ways, but
I know this topic has been discussed before on Stack Overflow. But there are
I know this topic has already been asked here, but I don't understand why
I know this question has been asked before, but many answers don't give clear
i know this topic has been discussed here before but i still can't get

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.