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