使用Javascript删除表中的按钮不起作用。我无法获得编辑按钮的值。我有这个代码:

时间:2021-11-26 09:18:11
$(".btn-add-dependent").click(function () {
  var checked = $("#disability").is(':checked') ? "checked='checked'" : "";
  $("#dependents-info tbody").append(
     "<tr><td>" + $("#first-name").val() + "</td><td>" 
     + $("#middle-name").val() + "</td><td>" 
     + $("#last-name").val() + "</td><td>" 
     + $("#dependents-birthday").val() 
     + "</td><td><input type='checkbox' disabled='disabled'" + checked 
     + "</td><td><button><span class='btn-edit-dependent glyphicon glyphicon-pencil'></span></button><button><span class='btn-delete-dep glyphicon glyphicon-trash'></td></tr>");
  });

  // delete dependent button
  $('.btn-delete-dep').click(function () {
     alert('m;lasfdj;adsdas');
  });

1 个解决方案

#1


0  

$('#dependents-info').on('click','.btn-delete-dep',function () {
     alert('m;lasfdj;adsdas');
});

#1


0  

$('#dependents-info').on('click','.btn-delete-dep',function () {
     alert('m;lasfdj;adsdas');
});