0

I've un problem with an .append with jQuery where i generate an input type button. I want to put an event on the button who from to the .append . Do you think that it is possible ?

I show you the code :

$('#MatchSeason').append("<tr><td>" + ui.item.label + "</td>" +
                         "<td id=" + 'Id' + " style=" + 'display:none' + ">" + ui.item.value + "</td>" +
                         "<td id=" + 'GroupingId' + " style=" + 'display:none' + ">" + ui.item.GroupingId + "</td>" +
                         "<td id="+'btnDeleteCell'+"><input type="+'button'+" id="+'btnDelete'+" name="+'btnDelete'+" value="+'Supprimer'+" </td>"+"</tr>"
                        )    


$('#btnDelete').click(function () {
            alert('test') 
});       

Thanks for the answers !

Valentin Mercier
  • 5,056
  • 3
  • 24
  • 49
Julien698
  • 576
  • 3
  • 7
  • 25

1 Answers1

1

try

$(document).on('click','#btnDelete',function () {
      alert('test') 
});

or

$('#MatchSeason').on('click','#btnDelete',function () {
      alert('test') 
});
Tamil Selvan C
  • 18,342
  • 12
  • 44
  • 63