代码:
<html>
<head>
<script type="text/javascript" src="/jquery/jquery.js"></script>
<script type="text/javascript">
$(function(){
$("input[type='button']").click(function() {
$("input[name='test']:checked").each(function() { //:checked 选择器选取所有选中的复选框或单选按钮。
n = $(this).parents("tr").index();
$("table#test_table").find("tr:eq("+n+")").remove();// 获取checkbox所在行的顺序 从0开始
});
});
});
</script>
</head>
<body>
<table id = "test_table">
<tr><td><input type="checkbox" name="test"></td><td>你好</td><td>你好</td><td>你好</td></tr>
<tr><td><input type="checkbox" name="test"></td><td>你好</td><td>你好</td><td>你好</td></tr>
<tr><td><input type="checkbox" name="test"></td><td>你好</td><td>你好</td><td>你好</td></tr>
<tr><td><input type="checkbox" name="test"></td><td>你好</td><td>你好</td><td>你好</td></tr>
</table>
<input type="button" value="删除">
</body>
</html>