复选框判断全选与否以及选中删除

做了一个仿邮箱的页面

要做成的效果是:勾选上面的复选框,代表全选,下面的也会勾上,然后然后点击删除时,选中的一行都会删除掉。

html 和css代码省略掉,直接js:

//全选与否
                $("table td input[type = checkbox]").click(function(){
                    if(this.checked){
                        $(".emailDetail li .opreation input[type = checkbox]").prop("checked",true);
                    }else{
                        $(".emailDetail li .opreation input[type = checkbox]").prop("checked",false);
                    }
                })
                //点击删除所选中的
                $(".receivingMenu .del").click(function(){
                      $(".emailDetail li .opreation input[type = checkbox]:checked").each(function(){//each循环遍历所选中的
                          var n = $(this).parents("li").index();
                          $(".emailDetail").find("li:eq("+n+")").remove();
                      })
                })
无才难做千里马,有志可吞九霄云!
原文地址:https://www.cnblogs.com/lfvkit/p/9922366.html