全选与取消【jQuery实例】

来源:互联网 发布:mac添加桌面小组件 编辑:程序博客网 时间:2024/06/13 19:32
//页面部分<label style="color:#444;">全选:</label><input type="checkbox" onclick="selectall()" id="check_box" title="全选">//全选jQ部分function selectall(){     if($('#check_box').prop('checked'))    {      $(':checkbox').prop('checked', true);    }else{      $(':checkbox').prop('checked', false)    }}
//第二种方法function selectAll(){    var obj=document.getElementById('check_box');    if(obj.checked==true){        $('form#group_list_info input[type="checkbox"][name="groupids[]"]').each(function(index,element){            this.checked=true;        })    }else{        $('form#group_list_info  input[type="checkbox"][name="groupids[]"]').each(function(index,element){            this.checked=false;        })    }}
原创粉丝点击