。单击.append(

时间:2014-07-21 15:08:52

标签: javascript jquery html

我使用jQuery的.append没问题,我生成一个输入类型按钮。我想在按钮上添加一个事件,从.append到.append。你觉得有可能吗?

我给你看了代码:

$('#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') 
});       

感谢您的回答!

1 个答案:

答案 0 :(得分:1)

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

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