解决方案可以使用 jQuery 或纯 JavaScript。
我想在用户单击表行单元格中包含的相应按钮后删除表行,例如:
<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>
你可以使用 jQueryclick
而不是使用onclick
属性,请尝试以下操作:
$('table').on('click', 'input[type="button"]', function(e){
$(this).closest('tr').remove()
})
Demo http://jsfiddle.net/7zWB5/1/
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)