如何在检查此行中的复选框后使用jquery html表行删除?
<table id="mainTable">
<tr>
<th>
name
</th>
<th>
remove
</th>
</tr>
<tr>
<td>
<input type="text" />
</td>
<td>
<input type="checkbox" id="chb1" />
</td>
</tr>
<tr>
<td>
<input type="text" />
</td>
<td>
<input type="checkbox" id="chb2" />
</td>
</tr>
</table>
例如,我选择id为chb2的复选框,并希望删除第二行
答案 0 :(得分:3)
对当前和未来的行尝试此操作:
$('input:checkbox').live('click',function() {
$(this).closest('tr').remove();
});
答案 1 :(得分:2)
试试这个:
$('input:checkbox').click(function() {
$(this).parent().parent().remove();
});