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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T11:19:32+00:00 2026-06-02T11:19:32+00:00

First question here as a user, so please take it easy on this noob!

  • 0

First question here as a user, so please take it easy on this noob!

Anyway, had a quick question concerning jQuery tabs. Not the UI version, rather, a different version. What I’m trying to do is be able to activate a link from a separate navigation area, but get the selected tab to appear as “current” Here’s the script I’m using:

<script type="text/javascript">
$(document).ready(function(){
$('#tabs div').hide();
$('#tabs div:first').show();
$('#tabs ul li:first').addClass('active');

$('#tabs ul li a').click(function(){
    $('#tabs ul li').removeClass('active');
    $(this).parent().addClass('active');
    var currentTab = $(this).attr('href');
    $('#tabs div').hide();
    $(currentTab).show();
    return false;
});
$('#sitenav ul li a').click(function(){
        $('#tabs ul li').removeClass('active');
        $(this).parent('#tabs ul li a').addClass('active');
        var currentTab = $(this).attr('href');
        $('#tabs div').hide();
        $(currentTab).show();
        return false;
});
});
</script>

And here is the secondary navigation accessing this:

<div id="sitenav">
    <ul>
    <li class="home"><a href="/search/">Search ISU...</a></li>
    <li><a href="#tab1" title="Faculty/Staff">Faculty/Staff</a></li>
    <li><a href="#tab2" title="Student">Student</a></li>
    <li><a href="#tab3" title="Department">Department</a></li>
    <li><a href="#tab4" title="Website">Website</a></li>
    </ul>   
</div>

Just for aesthetic reasons, here is the original navigation for the actual tabbed areas:

<div id="tabs">
<ul>
<li><a href="#tab1">Faculty/Staff</a></li>
<li><a href="#tab2">Student</a></li>
<li><a href="#tab3">Departments</a></li>
<li><a href="#tab4">ISU Website</a></li>
</ul>

(the ending tag for the “tabs” div is at the bottom of the document encircling all the content areas, which work fine…just an fyi! 🙂 )

What I was able to do was get the “sitenav” to actually link to the other areas, but for the life of me, I cannot get the tab to highlight and become “current”. Surely it’s something small that I just keep overlooking, but perhaps fresh eyes might see it! Thank you all!

edit: jeez…almost forgot. here is the test version of this thing in action, sort of: http://www.indstate.edu/search/index1.htm

  • 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-02T11:19:33+00:00Added an answer on June 2, 2026 at 11:19 am

    So if you click on #tab1 you want on the other list highlighted?
    I would do it like this:

    $('#sitenav ul li a').click(function(){
        $('#tabs ul li').removeClass('active');
        var currentTab = $(this).attr('href');
        $('#tabs ul li a[href="'+currentTab +'"]').parent().addClass('active');
        $('#tabs div').hide();
        $(currentTab).show();
        return false;
    });
    

    if you navigate from another page, the page renders from scratch so it won’t matter what you have set on the last page as an active tab or hash. if you want to select the active tab and show the activated element you’ll have to do it when the page loaded.
    so in that case I would make sure that in my css #tabs div has display: none; and none of the lis have active class by default.
    and you’d need something like this:

    $(document).ready(function(){
        var currentTab;
        if(window.location.hash){
           // check if this is an existing tab
            if($('#tabs ul li a[href="'+window.location.hash+'"]').length > 0){
                 currentTab = window.location.hash;
            }
        }
        if(currentTab){
           //select and show the current tab
           $('#tabs ul li a[href="'+currentTab +'"]').parent().addClass('active');
           $(currentTab).show();
        } else {
           //select and show the first tab
           $('#tabs div:first').show();
           $('#tabs ul li:first').addClass('active');  
        }
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

this is my first question here so I hope I can articulate it well
this is my first question here :) I know that I should not check
This is my first question here so try to make my best so you
Greetings to all! This is my first question here on stackoverflow. I have a
Ok, I need help. This is my first question here. Background: I am working
this is my first question to stackoverflow so here it goes... I use cruise
quick question here. I'm wondering how to create a 2D vector from user input.
First question here: it is a very short yet fundamental thing in Java that
First question here so hello everyone. The requirement I'm working on is a small
First Question in here :) (AS3) First off, how do I access a variable

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.