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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 18, 20262026-05-18T03:16:05+00:00 2026-05-18T03:16:05+00:00

After what seems like a very long time trying to find a solution, I

  • 0

After what seems like a very long time trying to find a solution, I thought it’s about time to ask the experts.

I have implemented jQuery tabs to my site, however as well as selecting a tab to show the content, I would also like to be able to show the different tabs content if you click on a standard html link elsewhere on the page.

The page can be seen here http://www.luxury-spa-breaks.com/spa-deals-TEST.html and the html links in question are those down the left hand side (e.g. the user can either select the tab they want or select a region from the left hand side, which would then display that regions tab content).

This is the js I currently have:

$(document).ready(function() {

 //When page loads...
 $(".tab_content").hide(); //Hide all content
 $("ul.tabs li:first").addClass("active").show(); //Activate first tab
 $(".tab_content:first").show(); //Show first tab content

 //On Click Event
 $("ul.tabs li").click(function() {
  $("ul.tabs li").removeClass("active"); //Remove any "active" class
  $(this).addClass("active"); //Add "active" class to selected tab
  $(".tab_content").hide(); //Hide all tab content

  var activeTab = $(this).find("a").attr("href"); //Find the href attribute value to identify the active tab + content
  $(activeTab).fadeIn(2000); //Fade in the active ID content
  return false;
 });
});

You’re help is massively appreciated!

Andy

  • 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-18T03:16:06+00:00Added an answer on May 18, 2026 at 3:16 am

    The easiest way to add the same functionality is to add the tabs class to the lefthand sidebar, or alternatively, add a selector that selects the sidebar menu to the selector for the tabs.

    At this point I would suggest swapping out the code you have there for the one which I rewrote for another Stack Overflow question. It’s more efficient and slightly cleaner by conforming to best practises.

    var tabContents = $(".tab_content").hide(),
        tabs = $("ul.tabs li, .anynavbar ul li"); // Second selector to match left hand sidebar
    
    tabs.first().addClass("active").show();
    tabContents.first().show();
    
    tabs.click(function() {
        var $this = $(this),
            activeTab = $this.find('a').attr('href');
    
        if(!$this.hasClass('active') && activeTab.length > 1 && activeTab.indexOf('#') === 0){
            $this.addClass('active').siblings().removeClass('active');
            tabContents.hide().filter(activeTab).fadeIn();
        }
    
        return false;
    });
    

    By doing either of the above, we can add the event handlers necessary to cause the tabs to change.

    I’ve also edited the code to add in a simple check for valid href values for use with your HTML, where some of the anchors lack the correct corresponding href values to activate the correct tabs. Also, looking at the code you’re using right now, you’ve missed out a }); at the end for the document.ready handler, which is why the code isn’t working.

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

Sidebar

Related Questions

I have an application that seems to throw exceptions only after the program has
I have a problem that seems like its a result of a deadlock-situation. Whe
After having looked at each of these two projects, it seems that both are
After some years of experience in the field, it seems to me that the
I'm getting back into .NET development after a couple years and it seems that
I'm following this tutorial (seems good) for Rails. After I run ruby script/generate scaffold
A coworker of mine has this problem, apparently after installing Re#, which seems totally
I spent a long time learning how to customise WCF from the point of
I’m after some thoughts on how people go about calculating database load for the
I would really like to make this question very clear for all of us.

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.