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

199
Visualizações
How to order div positioning in javascript?

I'm trying to order div depending on what comes from the url, let me explain,

http://127.0.0.1:5500/index2.html?group=teams&card=pro

I have the "teams" group and I have the card that starts with "pro"

then what you should do is order the cards depending on what you put in the url, that is, if it is "pro" let the "pro" card be first, if I search for ultra it leaves the "ultra" card first.

<div class="container-equipos" id="equipos">
<div class="equipos" data-equipo="1">
    <img src="./img/telefono.png" alt="">
    <p>Plan Libre Pro</p>
</div>
<div class="equipos" data-equipo="2">
    <img src="./img/telefono.png" alt="">
    <p>Plan Libre Plus</p>
</div>
<div class="equipos" data-equipo="3">
    <img src="./img/telefono.png" alt="">
    <p>Plan Libre Ultra</p>
</div>
var urlSearchParams = new URLSearchParams(window.location.search);
if (urlSearchParams) {

    var card = urlSearchParams.get('card')
    var group = urlSearchParams.get('group')
    var tab = urlSearchParams.get('tab')


   var equipos = document.querySelector('#equipos');
   var internet = document.querySelector('#internet');
   var planes = document.querySelector('#planes');

switch(group){
  case 'equipos': {
    equipos.classList.add('active');
    if(equipos.classList.contains('active')){

        var $wrap = $('.container-equipos');
        $wrap.find('.equipos').sort(function(a, b){
           if(card == 'pro'){
                    return 1;
                }else if(card == 'plus'){
                    //I'm missing this part

                } else if(card == 'ultra'){
                    return -1;
                }
            
            }
        }).appendTo($wrap);
    }
    break;
   }
 }
 }

This is what I have, but I don't know how to order them with sort, since sort orders me from the first to the last or from the last to the first but not the second... thanks for help

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