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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T05:26:13+00:00 2026-05-13T05:26:13+00:00

I am trying to swap the selected class from tab to tab to display

  • 0

I am trying to swap the selected class from tab to tab to display which one is current

Sample Code

$("li.selected").idTabs(function(id,list,set){ 
$("a",set).removeClass("selected") 
.filter("[@href='"+id+"']",set).addClass("selected"); 
for(i in list) 
  $(list[i]).hide(); 
$(id).fadeIn(); 
return false; 
}); 

so on click I am trying to remove and load the selected class with no luck, tried this

<ul class="idTabs">
  <li class="selected"><a href="#request-info">Request more information</a></li>
  <li><a href="#test-drive">Request a test drive</a></li>
  <li><a href="#make-offer">Make an offer</a></li>
  <li><a href="#get-quote">Get a quote</a></li>
</ul>

$('.idTabs li').click(function(){
$('.idTabs li').removeClass('selected');
  $(this).addClass('selected');
  return false;
});
  • 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-13T05:26:13+00:00Added an answer on May 13, 2026 at 5:26 am

    Aaron, your second example seems like it should work, but only works on the first two list items for some reason. I added classes to the li’s to make the selector more specific and it works fine now.

    <ul class="idTabs">
        <li class="navTab selected"><a href="#request-info">Request more information</a></li>
        <li class="navTab"><a href="#test-drive">Request a test drive</a></li>
        <li class="navTab"><a href="#make-offer">Make an offer</a></li>
        <li class="navTab"><a href="#get-quote">Get a quote</a></li>
    </ul>
    
    $('.navTab').click(function(){
        $('.navTab').removeClass('selected');
        $(this).addClass('selected');
        return false;
    });
    

    Regarding your comment below:

    It works every time when you click on an li… does not work when clicking on the anchor text because the click handler is not attached to that. You should add “display: block;” to your anchor within your li to expand the click area to the entire li (you will need to remove the padding from your li and in turn pad your ‘a’ so that the entire li is clickable). then… move the click handler to the anchor and have it change the parent’s (li) class. I’m thinking it should go something like this (I’m not able to test it out right now):

    $('.navTab a').click(function(){
        $('.navTab').removeClass('selected');
        $(this).parent().addClass('selected');
        return false;
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to swap out one class for another when a page loads depending
I am trying to swap two adjacent nodes in a linked list, and I
I am trying to swap between array and pointer in c++ My code is
I'm trying to swap two std::list< dontcare* >::iterators under Visual 2005. Iter it1 =
Im trying to change from big endian to little endian on a double. One
I'm trying to run the following code to swap filenames. I'm using Runtime.exec .
I'm trying to implement the Copy-and-Swap Idiom for my class, because I need to
Hi I'm trying to do a simple swap of two objects.My code is void
How can I swap the last two nodes of a linked list? I'm trying
I'm trying to write a function to swap 2 elements in a 2D array:

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.