<title>jQuery一句话实现多选框全选/取消</title>
 <script src="jquery-1.8.2.js" type="text/javascript"></script>
    <script type="text/javascript">
        function selectAll(obj) {               //$('input[type=checkbox]').attr('checked'(checkbox).attr('checked'));

//此处最好是用getElementsByName去取相关标签属性,用getElementById根据id去取是不行的,没有效果。
            var arr = window.document.getElementsByName("obj");
            //var arr = window.document.getElementById("obj");
            for (var i = 0; i < arr.length; i++) {
                arr[i].checked = obj.checked;
            }
        }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <input type="checkbox" name="obj" />
        全选<br />
        <input type="checkbox" name="obj" /><br />
        <input type="checkbox" name="obj" /><br />
        <input type="checkbox" name="obj" /><br />
        <input type="checkbox" name="obj" /><br />
        <input type="checkbox" name="obj" /><br />
        <input type="checkbox" name="obj" /><br />
        <input type="checkbox" name="obj" /><br />
        <input type="checkbox" name="obj" /><br />
        <input type="checkbox" name="obj" /><br />
    </div>
    </form>
</body>
</html>