0

I am trying to have a click event on < tr > tag of my table that's dynamically generated. While registering event for 1st time, there is no exception. But Function is not being called if I click on tablerow.

I tried getElementById also, which is even giving extra exception while registering on click event.

Please help.

Below is part of my code:

Script:

$("#empName").on("click", function(){
        alert("Hi");
    });

HTML:

$(obj).find('#abc tr:last').after("<tr class='odd' id='empName'><td>"+emp+"<br/>"+eventName+"</br>"+ind+"</br>"+loc +"</td></tr>");
Pratik
  • 307
  • 2
  • 4
  • 11

2 Answers2

0

Try following

$("#abc #empName").on("click", function(){
    alert("Hi");
});
Lepanto
  • 1,393
  • 1
  • 7
  • 15
0

Try this

 $(document).on("click","#empName", function(){
        alert("Hi");
    });
Yes Kay Selva
  • 584
  • 4
  • 13