全选反选按钮简单例子
//全选按钮处理$(function(){//点击全选$("#checkAll").click(function () {//当点击全选框时 var flag = $("#checkAll").is(":checked");//判断全选按钮的状态 var checkItems=document.getElementsByName("checkItem");for(var i=0;i<checkItems.length;i++){checkItems[i].checked = flag;}});//点击子项 $("input:checkbox[name='checkItem']").each(function(){$(this).click(function(){if($("input:checkbox[name='checkItem']:checked").length==$("input:checkbox[name='checkItem']").length){document.getElementById("checkAll").checked = true;}else{document.getElementById("checkAll").checked = false;}}); });});