Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

190
Vistas
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 la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda