简体   繁体   中英

Delete button in a table using Javascript doesn't work. I cannot get the value of the edit button. I have this code:

$(".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');
  });
$('#dependents-info').on('click','.btn-delete-dep',function () {
     alert('m;lasfdj;adsdas');
});

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM