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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T21:41:47+00:00 2026-06-13T21:41:47+00:00

I have a list of 20 items. I am using jquery drag and drop

  • 0

I have a list of 20 items. I am using jquery drag and drop to allow the user to sort the list of items. I would like the top 10 items in the list to remain the same color, lets say yellow, as the items are rearranged. For instance, if the #19 item is dragged up to within the top ten, the #10 item will be pushed to #11 and the items which should be yellow would be #’s 1,2,3,4,5,19,6,7,8,9.

No matter which order, the top ten should remain yellow. The rest are just black

I can not figure out how to do this. Can someone point me in the right direction?

Thanks in advance!

  • 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-13T21:41:48+00:00Added an answer on June 13, 2026 at 9:41 pm

    You did not tell us your html so I have to guess your using a html list. When sorting stops you have to get the position of the element and descide which color to assign

    http://api.jqueryui.com/sortable/#event-stop

    and use index method

    Working example: http://jsfiddle.net/txm9y/

    $( "#sortable" )
        .sortable({
            stop: function(event, ui){
                $(this).trigger("markTopTen");
            }
        })
        .disableSelection()
        .bind("markTopTen", function() {
            $(this).find("li")
                .removeClass("topTen")
                .each(function(index){
                if(index < 10)
                    $(this).addClass("topTen");
            });
        })
        .trigger("markTopTen");
    

    Start sorting. Top ten will remain yellow while others are black.

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

Sidebar

Related Questions

I have a list of <li> items that are dragged using jQuerys drag/drop. I'd
I'm using jQuery UI's sortable list to allow the user to drag and change
What I have: I'm using jQuery to hide the last few list items in
I have a list of items, witch i use with the drag and drop
I have a Jquery Drag Drop List which I want to update immediately in
I have a list that uses Jquery UI drag drop sortable but when I
I've got a UL of items using jQuery UI that I have drag and
I have a horizontal jquery-ui drag drop list contained in a wrapper in which
I have a page ItemList that shows a list of items using div's. After
I have a list of items that are displayed using a ListView from 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.