我在程序中使用如下的代码可以删除多行,$("input:checked").parent().parent().remove();
但是我要是点击“全选”按钮,会连我的标题栏也删掉了,我不想删除标题栏,如果把这一行过滤掉?

解决方案 »

  1.   

    $("input:checked").eq(0).siblings().parent().parent().remove();
      

  2.   

    $("input[type=checkbox]:not(:first):checked").parent().parent().remove();
      

  3.   

    如果你把复选框放入到表格里面这样用是没有问题的
    $('#tab tbody input:checked').parent().parent().remove()
      

  4.   

    这个问题还是没有解决,$("input[type=checkbox]:not(:first):checked").parent().parent().remove();还是把所有的都删除了
      

  5.   

    :not(:first)这是提供一个思路,具体还要自己去根据HTML标签调整,你的HTML代码不贴出来,怎么知道你哪里有问题啊
      

  6.   

    <input type="checkbox" id="selectAll">
    $("input:checked[id!='selectAll']").parent().parent().remove()<input type="checkbox" item="1">$("input:checked[item]").parent().parent().remove()
      

  7.   

    <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>
      

  8.   

    我研究了一下,这种需求用gt(0),not(:first)都不能解决,因为只选择后面的框,不选择“全选”的那个框时就会出错,只能给全选框给个id,然后用id判断。
      

  9.   

    楼上这位师兄分析的很对,我确实是用not(:first)不能解决我的问题,我也不知道是为什么,在html页面里是可以的,但是在jsp页面里面是不可以的,具体的原因没时间研究。最后还是用$("input:checked[id !=selall]").parent().parent().remove();
    实现的,指定一个id就可以了,特此感谢,我现在就可以结贴了!