单击表格行删除按钮后删除表格行 [英] Remove table row after clicking table row delete button
本文介绍了单击表格行删除按钮后删除表格行的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
解决方案可以使用 jQuery 或纯 JavaScript.
Solution can use jQuery or be plain JavaScript.
我想在用户单击表格行单元格中包含的相应按钮后删除表格行,例如:
I want to remove a table row after user has clicked the corresponding button contained in the table row cell so for example:
<script>
function SomeDeleteRowFunction() {
//no clue what to put here?
}
</script>
<table>
<tr>
<td><input type="button" value="Delete Row" onclick="SomeDeleteRowFunction()"></td>
</tr>
<tr>
<td><input type="button" value="Delete Row" onclick="SomeDeleteRowFunction()"></td>
</tr>
<tr>
<td><input type="button" value="Delete Row" onclick="SomeDeleteRowFunction()"></td>
</tr>
</table>
推荐答案
您可以使用 jQuery click
而不是使用 onclick
属性,请尝试以下操作:
You can use jQuery click
instead of using onclick
attribute, Try the following:
$('table').on('click', 'input[type="button"]', function(e){
$(this).closest('tr').remove()
})
这篇关于单击表格行删除按钮后删除表格行的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文