let table = document.getElementsByClassName("table")[0]; let trieCroissant = false; let dat = ["intRank","strTeamBadge","strTeam","intPlayed","intWin","intDraw","intLoss","intGoalsFor","intGoalsAgainst","intGoalDifference","intPoints"]; let recherche = document.getElementById("myInput"); recherche.addEventListener('input', function(){ filtrer(recherche.value.toLowerCase()); }); trier(); function viderTable(){ let listeLigne = table.children; let i=0; while (listeLigne.length>i){ if (listeLigne[i].tagName === 'tr'){ table.removeChild(listeLigne[i]); } else{ i++; } } } function remplirTable(donnee=data){ for (let i=0; ia.intRank - b.intRank); } else{ data.sort((a,b)=>b.intRank - a.intRank); } viderTable(); remplirTable(); } function filtrer(filtre){ viderTable(); let dataFiltrer = data.filter(function(equipe){ if (equipe.strTeam.toLowerCase().startsWith(filtre)){ return equipe; } }); remplirTable(dataFiltrer); }