Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

260
Views
How to update z-index values in two related lists 'A,B'(B is sortable items)

The two list are A, and B. The list B is sortable (drag-drop), each item in list 'B' is related with each item in list 'A' by index ! we set first this css propety to list 'B' items

#sortable2 li:nth-child(1) {
  z-index: 10!important;
  background-color: rgb(149, 168, 228);

}

#sortable2 li:nth-child(2) {
  z-index: 9!important;
  background-color: rgb(69, 223, 31);

}

#sortable2 li:nth-child(3) {
  z-index: 8!important;
  background-color: rgb(230, 47, 123);

}  ```

when the page is loaded, it dynamically give z-index of each item in List 'B' to each item in List 'A'; like this:

List B: #sortable2 li List A:#textSegments .jmSeg

for(var i=0;i<=$('#sortable2 li').length; i++){
    
        console.log($('#sortable2 li').eq(i).css('z-index'));
        $('#textSegments .jmSeg').eq(i).css('z-index',$('#sortable2 li').eq(i).css('z-index'));
    }

my question is after resort List 'B' items the z-index values in list 'B' change depending on the position of the item(layer). The "top item" of list 'B' set the highest z-index value and the last item gets the lowest z-index value , but z-index of List 'A' no changes. i tried this code below code to update list A z-index but also no changes

 $('#sortable2').sortable({ ........
.....................................
 update: function (event, ui) {
        
        for(var i=0;i<=$('#sortable2 li').length; i++){
    
                    console.log($('#sortable2 li:nth-child('+i+')').css('z-index'));
                    $('#textSegments .jmSeg').eq(i).css('z-index',$('#sortable2 li:nth-child('+i+')').css('z-index'));
                }


  [1]: https://i.stack.imgur.com/4hXad.jpg
about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!