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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T09:49:08+00:00 2026-05-31T09:49:08+00:00

How would I go about remove the class from all elements except the next

  • 0

How would I go about remove the class from all elements except the next one?

For example:

<ul>
  <li class="current"><a href="#">Trigger</a></li>
  <li class="next"><a href="#">Trigger</a></li>
  <li class="next"><a href="#">Trigger</a></li>
  <li class="next"><a href="#">Trigger</a></li>
</ul>

Clicking on Trigger link a removes all the "next" classes from the li elements except the one directly below

I’m not worried about the whole set of code to achieve this. I’ve written everything that I need apart from this one thing of removing the class except on the next li?!

UPDATE: SOLVED

Seems I overlooked a simple solution which works well:

$(this).parent().siblings().not().next().removeClass('next');
  • 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-31T09:49:10+00:00Added an answer on May 31, 2026 at 9:49 am

    Use the .nextAll method to get all consecutive siblings after the current element. Then, reduce the set using .slice(1).

    $('li a').click(function() {
        $(this).parent().nextAll().slice(1).removeClass('next');
    });
    

    The previous method only removes next from later items. If you want to affect all siblings, the following can be used:

    $('li a').click(function() {
        var $parent = $(this).parent();
        $parent.siblings().not($parent.next()).removeClass('next');
    });
    

    Another option: Remove the next class from all elements, then add it to the next element.

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

Sidebar

Related Questions

I'm trying to remove a class object from list<boost::any> l l.remove(class_type); I tried writing
I have a number of elements with the same class like this: <html> <head><title>example</title>
Coming from Java and using the ArrayList class has me all frustrated when trying
Any ideas how I would go about writing a javascript method to insert an
Just a quick question about how you would go about implementing this. I want
I would like to know how I would go about altering the HTML that
I'm wondering how i would go about making the following application: a user signs
Anyone have any idea how I would go about converting a timestamp in milliseconds
Does anyone know how I would go about changing (transforming) an image based on
I am wondering how I would go about performing a certain function if a

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.