jquery操作全选或全不选

来源:互联网 发布:黑马程序员培训多少钱 编辑:程序博客网 时间:2024/04/28 03:41

<script type="text/javascript">

            $(function(){

                //全选

                $("#select_all").click(function(){

                     if($("#select_all").attr("checked")=="checked"){

                         $(".checkedboxclass").each(function(){

                            $(this).attr("checked","checked");

                         });

                     }else {

                         $(".checkedboxclass").each(function(){

                            $(this).removeAttr("checked");

                         });

                     }

                    

                });

                $(".checkedboxclass").click(function(){

                    if($("#select_all").attr("checked")=="checked"){

                        $("#select_all").removeAttr("checked")

                    }

                });

            });

            

        </script>


<input type="checkbox" class="checkedboxclass"/>

<input type="checkbox" class="checkedboxclass"/>

<input type="checkbox" class="checkedboxclass"/>

<input type="checkbox" id="select_all"/>

0 0