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

189
Views
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
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!