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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:50:54+00:00 2026-06-13T11:50:54+00:00

I want to delete an entry from a user list and the rows classes

  • 0

I want to delete an entry from a user list and the rows classes should be rearrange, so that no two consecutive rows have the same class. How can I reorder the rows classes after deleting an item from the list? For example: If I delete the item ‘five’, the elements ‘four’ and ‘six’ have the same rows classes.

<!DOCTYPE html>
<html>
<head>
    <title>Test</title>
    <meta http-equiv="content-type" content="text/html;charset=utf-8" />
<script type="text/javascript" src="jquery-1.8.2.min.js" charset="utf-8"></script>
<style type="text/css">

ul#users { list-style:none; margin:0 auto; width:50%; }
ul#users li { padding:3px; cursor:pointer; }

ul#users li a.delete { float:right; }
ul#users li.col0 { background:#ffffff; }
ul#users li.col1 { background:#fbfbfb; }
ul#users li.col2 { background:#fdffce; }


</style>
<script type="text/javascript">

$(document).ready(function(){

    // hover class
    var clshover = "col2";

    // confirm message
    var msgconfirm = "You really want to delete this entry?";

    // Hover effect
    $('ul#users > [class^=col]').hover(
        function () {
            $(this).addClass(clshover);
        },
        function () {
            $(this).removeClass(clshover);
        }
    );

    // Delete a defined entry
    $('ul#users > li > a.delete').click(function (){
        if (confirm(msgconfirm)) {
            $(this).parents('li').remove();
        }
    });

});

</script>
</head>

<body>

<ul id="users">
    <li id="users0" class="col0">one<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users1" class="col1">two<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users2" class="col0">three<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users3" class="col1">four<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users4" class="col0">five<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users5" class="col1">six<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users6" class="col0">seven<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users7" class="col1">eight<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users8" class="col0">nine<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
    <li id="users9" class="col1">ten<a href="javascript:;" class="delete" title="Delete">&nbsp;x&nbsp;</a></li>
</ul>

</body>
</html>
  • 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-13T11:50:55+00:00Added an answer on June 13, 2026 at 11:50 am

    Try changing your JS to something like this:

    <script type="text/javascript">
    
    $(document).ready(function(){
    
        function reassign()
        {
        var i =0;
        $.each($('ul#users > li'), function() {
                $(this).attr('class', 'col' + (i % 2));
                i++;
        });
        }
    
        // hover class
        var clshover = "col2";
    
        // confirm message
        var msgconfirm = "You really want to delete this entry?";
    
        // Hover effect
        $('ul#users > [class^=col]').hover(
            function () {
                $(this).addClass(clshover);
            },
            function () {
                $(this).removeClass(clshover);
            }
        );
    
        // Delete a defined entry
        $('ul#users > li > a.delete').click(function (){
            if (confirm(msgconfirm)) {
                $(this).parents('li').remove();
                reassign();
            }
        });
    
    });
    
    </script>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to delete an entry from my Database but it says it can't
I want to delete DataRows from a DataTable. The rows to be deleted are
I want to delete files from a specific directory recursively. So, I have used
I want to delete the most recent entry in MySQL using PHP, is there
I want to delete all rows in a datatable. I use something like this:
I want to delete an array index from an array, then reload listView with
I want to delete a number of jobs from a q. The command to
I'm making a mock-media player program that allows the user to input,edit,delete and view
I want to delete an entry in my PAGES table. Upon deletion of it,
I have 10 GB of data in fs.chunks and I want to delete every

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.