单击表行删除按钮后删除表行

解决方案可以使用jQuery或纯JavaScript。

我想在用户单击表格行单元格中包含的相应按钮后删除表格行,例如:

 function SomeDeleteRowFunction() { //no clue what to put here? }  

您可以使用jQuery click而不是使用onclick属性,请尝试以下操作:

 $('table').on('click', 'input[type="button"]', function(e){ $(this).closest('tr').remove() }) 

演示

你可以这样做:

  

以下解决方案工作正常。

HTML:

 

JQuery的:

 function SomeDeleteRowFunction(btndel) { if (typeof(btndel) == "object") { $(btndel).closest("tr").remove(); } else { return false; } } 

我在http://codebins.com/bin/4ldqpa9上做过垃圾箱