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

209
Vistas
.getElementByClassName doesn't recognize Ajax.GET elements?

This is the problem that i encountered:

I have an api that makes an Ajax.GET and in the success function, creates a button, a div, and a bunch of span with information in it, and a class for each one of them. That same GET, shows all the info of the db correctly inside of a already existing div in the HTML document, but when i want to make a function which the result does a "console.log("clicked")", it doesn't recognize the data from the get.

If I make a button with a class, it does recognize it tho.

What am i doing wrong? Thanks in advance!

enter image description here

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

You are attaching the listener to the element, when it is non existent (AJAX not yet done executing). Attach the event when the element is created and appended to the div. I would do that by moving the event attachment to the success function of the AJAX.

over 4 years ago · Santiago Trujillo 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