0

I am generating the html table dynamically using javascript. Adding the button for each row and a css class for that, the onlick event for that css class is not getting called. Need a help where I am making a mistaking.

Here is my code for reference

for(var i=0;i<5;i++){
$("#desgtable").append("<tr rowindex='Number(i+1)'><td>"+i+"</td><td><input type='button' class='case' </td></tr>");

 }


 $(".case").click(function(){
     alert();
} 
Madhan
  • 41
  • 2
  • 8

1 Answers1

1

Use event delegation:

 $(document).on('click',".case",function(){
     alert();
});
Nikhil Batra
  • 3,118
  • 14
  • 19