<input type="button" class="btn_selectallbg" id="checkall2" value="全选" />
<input type="checkbox" name="groupId[]" value="遍历的某列值 " />
// 给全选按钮添加全选功能 $('#checkall2').toggle(function(){ $("input[name='groupId[]']").each(function(){ $(this).attr('checked',true); }); $(this).attr('value','取消'); },function(){ $("input[name='groupId[]']").each(function(){ $(this).attr('checked',false); }); $(this).attr('value','全选'); }