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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:39:19+00:00 2026-06-09T14:39:19+00:00

I need to highlight the tab which is for the current page with jquery.

  • 0

I need to highlight the tab which is for the current page with jquery. A simple task usually with a few lines of code I know. However, the tab is not your usual thing as I have a toolbar and have done it with spans. The span for the tab is inside the link so that the tab can be clicked as well as the text inside it. Since I only have two tabs that are links on the toolbar I was thinking of using an if else statement in jquery to determine which page the user is on and therefore which tab to highlight but i am not too sure how to do that.

The markup for the tabs is;

 <a href="Home">
     <span class="navButton" title="Return Home">
         Home
     </span>
 </a>
 <a href="Discover">
     <span class="navButton" title="Discover The Unsigned">
          Discover
     </span>
 </a>

The jquery I have at the moment that doesnt work is;

 $(function(){
     var path = location.pathname.substring(1);
     if ( path )
     $('#navButton a[href$="' + path + '"]').css ('box-shadow', 'inset 0 0 10px #000000');
 });

Note: I will be adding the css style rather than a class as it will keep other things simpler.

  • 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-09T14:39:20+00:00Added an answer on June 9, 2026 at 2:39 pm

    Why don’t you want to change style onClick()? Like that:

    $("#navButton a").click(function() {
        $(this).css('box-shadow', 'inset 0 0 10px #000000');
    });
    

    Or even better, you can create CSS class:

    .activeTab {box-shadow: inset 0 0 10px #000000;}
    

    And then add / remove it, depending on currently active tab:

    $("#navButton a").click(function() {
        $(".activeTab").removeClass("activeTab");
        $(this).addClass("activeTab");
    });
    

    Based on location:

    $(function() {
        var url = window.location.path;
        $('$navButton a[href="' + url + '"]').addClass("activeTab");
    });
    

    And then your links should look like:

    <a href="'/someDirectory/one.html'">One</a>
    <a href="'/someDirectory/two.html'">Two</a>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to highlight the current page in my left nav. The nav has
I'm using jquery to create tabs, which works fine by adding a class=current to
I need to highlight the differences between two simple strings with python, enclosing the
I need to highlight source code in LaTeX. The package listings seems to be
Hello i need to highlight a div after my page is loading, i don't
I have a paragraph of text in which I need to highlight some key
I'm working on an asp.net application which uses Lucene.net I need to highlight the
I'm using the jquery.highlight plugin: http://code.google.com/p/gce-empire/source/browse/trunk/jquery.highlight.js?r=2 I'm using it to highlight search results. The
I write articles on my blog and I need to highlight the source code(java,
I need to highlight or create markers on some annotations using meta information, which

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.