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

118
Vistas
jQuery on change of last element which is dynamically added

I need to run jQuery on the last element of a specific class that is dynamically generated.

Classically I would use:

    $(".class").last().on("change", function(){
       something();
    });

but since the .class element is generated through jQuery after the page is rendered, I have to use:

$("body").on("change", ".class", function(){
  something();
});

but this entry causes the change in the first (or any) element on the page to trigger the event.

I would need to somehow include the .last() function into the second selector.

Simply: I have an input on the page that is empty, when a change is made to it, a copy of this input with empty content should be generated and inserted after the first input. If this one is filled, another one is generated. Currently (using $("body").on("change",...) the next input is generated again and again even if I change the first input field X times.

Thanks everyone

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You can ask

$("body").on("change", ".class", function(){
  if($(this).is(':last-child')) {
    //something
  }
});
about 4 years ago · Juan Pablo Isaza Denunciar
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