全选/全不选

全选/全不选

HTML code 

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
    <script src="Scripts/jquery-1.4.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        function selectAll(checkbox) {
            $('input[type=checkbox]').attr('checked', $(checkbox).attr('checked'));
        }
        </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <input type="checkbox" onclick="selectAll(this);" />全选<br/>
        <input type="checkbox"  /><br/>
        <input type="checkbox"  /><br/>
        <input type="checkbox"  /><br/>
        <input type="checkbox"  /><br/>
        <input type="checkbox"  /><br/>
        <input type="checkbox"  /><br/>
    </div>
    </form>
</body>
</html>
posted @ 2012-01-18 14:33  kangwl  阅读(89)  评论(0编辑  收藏  举报