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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 19, 20262026-05-19T16:19:16+00:00 2026-05-19T16:19:16+00:00

I am using jQuery to alternate the background colors and add radii to some

  • 0

I am using jQuery to alternate the background colors and add radii to some unordered list items like so:

// Alternate row colors for group listing and add top/bottom radii
$('li.groupList:even').css({backgroundColor: '#e4e4e4'});
$('li.groupList:odd').css({backgroundColor: '#ededed'});
$('li.groupList:first').addClass('rtm');
$('li.groupList:last').addClass('rbm');

However, if I remove one of the list items using the actual remove() method, the colors and radii do not update.

// Remove group members
$("[id^='removeGroupMember_']").click(function () {
    $(this).parent().slideUp("fast", function () {
        $(this).remove();
    });
});

Is this because the browser does not get notified of the list array change or is this something I should just be doing using CSS only (i.e. using li.groupList:nth-child(even) etc.)?

The reason I was using jQuery to begin with was because I assumed it was cross-browser compliant moreso than CSS3 selectors (but please enlighten me if you think otherwise!).

  • 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-19T16:19:17+00:00Added an answer on May 19, 2026 at 4:19 pm

    Call this function whenever you remove one of the list items:

    function update() {
        var l = $('li.groupList').removeClass('rtm rbm').removeAttr('backgroundColor');
    
        l.filter(':even').css({backgroundColor: '#e4e4e4'});
        l.filter(':odd').css({backgroundColor: '#ededed'});
        l.first().addClass('rtm');
        l.last().addClass('rbm');
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Using jQuery and not CSS, is it possible to alternate row colors between records?
I'd like to alternate the background color in a HTML un-ordered list without using
I've a code to sort table using Jquery.I use toggle function to alternate clicks,and
I would like an alternative to using callback method inside of jQuery's .val() method
Using jQuery Nearest Element , I would like to select elements in a circular
I'm using the jQuery validation plugin trying to add rules based on data- attributes.
How to alternate style (background color with jQuery) for div inside div with id=container
I'm using jQuery to create a simple, but large dropdown menu. I have some
I want to style alternate item in a list with a background color of
I'm trying to highlight just one specific row in a table using jQuery. The

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.