Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

259
Visualizações
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
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda