Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

201
Views
addEventListener no funciona para el botón dinámico

Tengo un botón creado dinámicamente, configuré la identificación y la clase para intentar establecer un addEventListener, pero el addEventListener no se lee en el DOM, pero sí la identificación y la clase.

aquí está mi código

 let button: HTMLButtonElement = document.createElement('button') button.id = "comment-button"; button.className = "comment-button";

(ID y clase están funcionando)

Esto es lo que he intentado:

 button.addEventListener("click", setComment); document.getElementById("comment-button")?.addEventListener("click", setComment);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Para recuperar un elemento del documento, debe agregar el elemento que creó al documento. document.body.appendChild(button)

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!