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

  • Home
  • SEARCH
  • 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 8910687
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T03:45:08+00:00 2026-06-15T03:45:08+00:00

This might be easy but I am having trouble in getting it to work.

  • 0

This might be easy but I am having trouble in getting it to work. I am using .each() to iterate through a list. I was wondering if it is possible to remove a class using the index.

eg. If there were 10 items in the list and I want to remove the class from the 5th element when I click the 8th element for example.

$(function () {
var items = $('#v-nav>ul>li').each(function (index) {
    $(this).click(function () {
        if (index = 8)
{
$(#5).removeClass('class');
}
    });
});

Anyone with any ideas? Thank you

  • 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-15T03:45:09+00:00Added an answer on June 15, 2026 at 3:45 am

    Change

    $(#5).removeClass('class');
    

    To

    $('#v-nav>ul>li:eq(4)').removeClass('class');
    

    Its better to assign the element returned by your selector to do the same processing again to get desired element.

    $(function () {
        var items = $('#v-nav>ul>li')
    
           $('#v-nav>ul>li').click(function () {
              if ($(this).index() = 8)
              {
                 $(items).eq(4).removeClass('class');
              }
           });
    });
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This might be easy, but I'm a JQuery dunce and keep getting errors! Basically,
This might be ridiculously easy for you but I've been struggling with this for
This might be an easy one, but I'm not really experienced with sql. I
This might seem an easy question for some, but I am struggling with it.
This might seem like a very easy question for some of you folks, but
I know this might sound easy. I thought about using the first dot(.) which
Ok, this might sound like a silly question, but I'm having all sorts of
this might be an easy question but i have a notification that when clicked
There might be an easy answer to this, but I can't for the life
This might be silly or very easy to do, but I have no clue

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.