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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T15:59:09+00:00 2026-06-17T15:59:09+00:00

I have a <ul> , in which I am using jQuery UI Sortable to

  • 0

I have a <ul>, in which I am using jQuery UI Sortable to allow the sorting of the contained <li>s.

The <li>s are styled with alternating background colours with :

.list-striped li:nth-child(odd) {
  background-color: #f9f9f9;
}

I am using the Sortable start and stop functions to create a nice transition when the <li> is dragged like so:

$( ".sortable" ).sortable({
        start: function(event, ui){
            $(ui.item).animate({
                'background-color': '#333333'
            }, 'fast');
        },
        stop: function(event, ui){
            $(ui.item).animate({
                'background-color': ''
            }, 'fast');
        }
    });

My issue now, is that when we clear the background colour, it doesn’t revert to the previous background colour (or inherit the background colour it should from the CSS). Is what I am trying to achieve possible?

  • 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-17T15:59:10+00:00Added an answer on June 17, 2026 at 3:59 pm

    Don’t use jQuery to animate colors, use CSS transitions instead:

    $( ".sortable" ).sortable();
    

    CSS:

    .list-striped li{
      width:200px;
      border:1px solid #ccc;
      padding:10px;
      transition: background 0.2s linear;
      -o-transition: background 0.2s linear;
      -moz-transition: background 0.2s linear;
      -webkit-transition: background 0.2s linear;
       cursor:pointer;
    }
    .list-striped li:nth-child(odd) {
      background-color: #faa;
    }
    .list-striped li.ui-sortable-helper{
      background-color:#a55 !important;
    }
    

    JSFiddle

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

Sidebar

Related Questions

I have the following ListView in which I am using the JQuery UI sortable
I'm using jQuery UI sortable to allow the user to shuffle the list, but
I have a page using jQuery with some lists which have been made sortable.
I have two lists in which using jQuery sortable i can move the items
I have built a sortable list using jQuery UI's sortable feature, this is working
With jQuery sortable, I have a very long list which forces a scrollbar. Whenever
I have a list on my website. I'm using jQuery's sortable tutorial to give
Hello there Iam using Jquery 1.6.2 and JqueryUI 1.8.16 I have a sortable list
I have a number of tables, which have nested tables. I using jQuery to
I have a MVC3 ASP.NET Project in which I am using jQuery and KendoUI

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.