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

234
Vistas
Why does this function to sort the rows of a table work in Firefox but not in chrome?

I have some code to sort the body of a table that is all numbers. It works on firefox, but on chrome it does not update the table. On chrome, the sort function does not seem to change the order of the tr elements in the array.

function sortTable(col, dir = 1) {

    var tb = document.getElementById("vote_table").tBodies[0];
    tr = Array.prototype.slice.call(tb.rows, 0);

    tr = tr.sort(
            function (a, b) 
            { 
                return dir*parseInt(a.cells[col].textContent) < dir*parseInt(b.cells[col].textContent);               
            }
       );
    
    alert(tr[0].cells[col].textContent);

    for(var i = 0; i < tr.length; ++i) 
    { 
        tb.appendChild(tr[i]);  
    } // append each row in order
}
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