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

215
Views
Event listener not firing when created at the same time as html

This event listener wont fire, have I built it correctly?

I am trying to add the event listener when each new line is added after being fetched from the database.

const renderEmployee = (element) =>{

let newRow =
`
<tr>
    <td>${element.lastName}</td>
    <td>${element.firstName}</td>
    <td>${element.email}</td>
    <td>${element.department}</td>
    <td>${element.location}</td>
    <td>
        <button data-empid="${element.id}" id="${element.id}Del"><i class="fa fa-trash" aria-hidden="true"></i></button>
        <button data-empid="${element.id}" id="${element.id}Edit"><i class="fas fa-edit"></i></button>
    </td>
</tr>

`
document.getElementById("employeeData").innerHTML += newRow;

// set event listeners for delete and edit 
$(`#${element.id}Del`).click(() => deleteEmployee($(`#${element.id}Del`).attr("data-empid")));
$(`#${element.id}Del`).click(() => console.log("test"));

}

about 4 years ago · Juan Pablo Isaza
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!