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

86
Vistas
Troubleshooting a Javascript class' click-event function

I have a JS 'shuffle' function that I am trying to execute every time a user clicks on the shuffleBtn class in my HTML. I am using classes over IDs because I have multiple shuffleBtn instances.

I'm not too familiar with JS/jQuery and can't see why my syntax is broken. Any pointers appreciated!

<script>

window.onload = function() {
  $('.shuffleBtn').on('click', function(){
  var refs = $(".ref");
    for(var i = 0; i < refs.length; i++){
        var target = Math.floor(Math.random() * refs.length -1) + 1;
        var target2 = Math.floor(Math.random() * refs.length -1) +1;
        refs.eq(target).before(refs.eq(target2));
    }
 };
 };
 
</script>
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