jQuery删除多行的问题,解决问题之后马上结贴。 我在程序中使用如下的代码可以删除多行,$("input:checked").parent().parent().remove();但是我要是点击“全选”按钮,会连我的标题栏也删掉了,我不想删除标题栏,如果把这一行过滤掉? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 $("input:checked").eq(0).siblings().parent().parent().remove(); $("input[type=checkbox]:not(:first):checked").parent().parent().remove(); 如果你把复选框放入到表格里面这样用是没有问题的$('#tab tbody input:checked').parent().parent().remove() 这个问题还是没有解决,$("input[type=checkbox]:not(:first):checked").parent().parent().remove();还是把所有的都删除了 :not(:first)这是提供一个思路,具体还要自己去根据HTML标签调整,你的HTML代码不贴出来,怎么知道你哪里有问题啊 <input type="checkbox" id="selectAll">$("input:checked[id!='selectAll']").parent().parent().remove()<input type="checkbox" item="1">$("input:checked[item]").parent().parent().remove() <html xmlns="http://www.w3.org/1999/xhtml"><head><title>juery:First example</title><script type="text/javascript" src="js/jquery.js"></script><style type="text/css"> table,table td{ border-style: solid; border-width: 1px; }</style><script type="text/javascript"> $('document').ready(function() { $("#selall").click(function() { $(":checkbox").attr("checked",$(this).attr("checked")); }); }); function del() { $("input:checked[id !=selall]").parent().parent().remove(); }</script></head><body><table id="tbl1" style=""> <tr> <td><input type="checkbox" id="selall" value="全选" /></td> <td>表头1</td> <td>表头2</td> </tr> <tr> <td><input type="checkbox" /></td> <td>02</td> <td>03</td> </tr> <tr> <td><input type="checkbox" /></td> <td>aaa</td> <td>bb</td> </tr> <tr> <td><input type="checkbox" /></td> <td>ddd</td> <td>ddd</td> </tr></table><input type="button" value="删除选中行" onclick="del();" /></body></html> 我研究了一下,这种需求用gt(0),not(:first)都不能解决,因为只选择后面的框,不选择“全选”的那个框时就会出错,只能给全选框给个id,然后用id判断。 楼上这位师兄分析的很对,我确实是用not(:first)不能解决我的问题,我也不知道是为什么,在html页面里是可以的,但是在jsp页面里面是不可以的,具体的原因没时间研究。最后还是用$("input:checked[id !=selall]").parent().parent().remove();实现的,指定一个id就可以了,特此感谢,我现在就可以结贴了! 如何通过js或者jquery获得tomcat服务器端的认证对话框? 通过ajax获取到html后,怎么执行其中的第一个方法??? JS 获取URL的问题 帮忙看看这段代码 客户端如何实现,选择不同的单选按钮选项,出现不同的table表格? 怎么访问注册表????? 如何将图片放大缩小? 如何防止用户查看客户端网页代码? 在多选框中实现某一功能问题? 怎么实现图片的水平方向和垂直方向同时平铺? 关于客户端javascript倒计时误差的问题 关于window.open打开指定浏览器问题
$('#tab tbody input:checked').parent().parent().remove()
$("input:checked[id!='selectAll']").parent().parent().remove()<input type="checkbox" item="1">$("input:checked[item]").parent().parent().remove()
<head>
<title>juery:First example</title>
<script type="text/javascript" src="js/jquery.js"></script>
<style type="text/css">
table,table td{
border-style: solid; border-width: 1px;
}
</style>
<script type="text/javascript">
$('document').ready(function() {
$("#selall").click(function() {
$(":checkbox").attr("checked",$(this).attr("checked"));
});
}); function del() {
$("input:checked[id !=selall]").parent().parent().remove();
}
</script>
</head>
<body>
<table id="tbl1" style="">
<tr>
<td><input type="checkbox" id="selall" value="全选" /></td>
<td>表头1</td>
<td>表头2</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>02</td>
<td>03</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>aaa</td>
<td>bb</td>
</tr>
<tr>
<td><input type="checkbox" /></td>
<td>ddd</td>
<td>ddd</td>
</tr>
</table><input type="button" value="删除选中行" onclick="del();" /></body>
</html>
实现的,指定一个id就可以了,特此感谢,我现在就可以结贴了!