简体   繁体   English

使用Javascript的表格中的“删除”按钮不起作用。 我无法获取编辑按钮的值。 我有以下代码:

[英]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');
});

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 单击按钮时,我想使用 JavaScript 插入文本。 但是 ```.value()``` 似乎不起作用 - I want to insert text using JavaScript when I click on button. But ```.value()``` doesn't seems to work 我似乎无法让我的悬停效果在按钮上工作。 尝试了很多技巧 - i can't seem to get my hover effects to work on button. have tried many tips 为什么这段代码行不通。 我在库p5中使用javascript - Why doesn't this code work. I'm using javascript with the library p5 如果我有参数,刷新页面的按钮不起作用 - Button to refresh page doesn't work if I have get parameters 如果我没有嵌套if / else语句,则代码不起作用。 我为什么要窝? - If I don't nest the if/else statements, the code doesn't work. Why do I have to nest? 当我单击“添加”按钮时,我想添加文本字段。 但它不起作用。 帮我 - I want to add text field when i clicked the button “add”. But it doesn't work. Help me 我有两个具有相同代码的不同域,但是其中一个不起作用。 为什么? - I have two different domains with the same code, but one of them doesn't work. Why? 我页面上有一个按钮,该按钮利用了一些Javascript代码来发布某些内容,但在移动设备上不起作用 - I have a button on my page which utilizes a bit of Javascript code to tweet something out but it doesn't work on mobile JavaScript代码不起作用。 为什么? - Javascript code doesn't work. Why? 我可以让下一个按钮工作,但不能让上一个按钮工作。 我究竟做错了什么? - I can get the next button to work but not the previous button. What am I doing wrong?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM