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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T01:27:49+00:00 2026-06-10T01:27:49+00:00

I have a script that removes a class for functional reasons, the problem is

  • 0

I have a script that removes a class for functional reasons, the problem is it strips out all the classes and not just the one that it should.

HTML

  <ul id="slidecontrols" class="sc-nav">
  <li class="dont-remove">
     <a href="#one" class="user-management shadow1">User Management</a>
  </li>
  <li class="dont-remove">
    <a href="#two" class="asset-management shadow1">Asset Management</a>
  </li>
   <li class="dont-remove">
    <a href="#three" class="reporting shadow1">Reporting & Analytics</a>
  </li>
  </ul>

jQuery that is adding the class .selected and removing the class .selected with all the other classes that are on that “li” element.

$(document).ready(function () {

//Set the initial state: highlight the first button...
$('#slidecontrols').find('li:eq(0)').addClass('selected');

//and hide all slides except the first one
$('#slides').find('> div:eq(0)').nextAll().hide();

//actions that apply on click of any of the buttons
$('#slidecontrols li').click(function (event) {

    //turn off the link so it doesn't try to jump down the page
    event.preventDefault();

    //un-highlight the buttons
    $('#slidecontrols li').removeClass();

    //hide all the slides
    $('#slides > div').hide();

    //highlight the current button
    $(this).addClass('selected');

    //get the index of the current button...
    var index = $('#slidecontrols li').index(this);

    //and use that index to show the corresponding slide
    $('#slides > div:eq(' + index + ')').show();

});

});

< /script>
  • 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-10T01:27:50+00:00Added an answer on June 10, 2026 at 1:27 am

    jsBin demo

    Instead of:

    $('#slidecontrols li').removeClass();
    

    Use:

    $('#slidecontrols li').removeClass('selected');
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this script and the rows that have td class odd will not
I have a script that recursively loops through all the sub directories and compresses
I have following script that executes all the .reg files in the current directory.
so I have this jQuery script below that works. But since I'm just learning
I have a piece of code that removes and add class 'selected' when the
I have a class that contains 2 functions one for removing post and one
I have this script that uses an a:href attribute tag to swap divs out.
I want to remove the class attribute from all elements that have an empty
I'm working on a table where all rows have at least one class. Some
Basically I have this problem. I have an accordion that toggles one heading open

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.