jquery 전체 선택 및 반전

<!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>
    <title></title>
    <script src="Scripts\jquery-1.7.1.min.js" type="text/javascript"></script>
    <script type="text/javascript">
        $(function () {
            $("#selectAll").click(function () {
                $("#playList :checkbox").attr("checked", true);
            });
            $("#unSelect").click(function () {
                $("#playList :checkbox").attr("checked", false);
            });
            $("#reverse").click(function () {
                $("#playList :checkbox").each(function () {
                    $(this).attr("checked", !$(this).attr("checked"));
                });
            });
        })
    </script>
</head>
<body>
    <h3>       ?</h3>
    <div id="playList">
    <input type="checkbox"  value="    "  />    <br/>
    <input type="checkbox" value="  " />  <br/>
    <input type="checkbox" value="    " />    <br/>
    <input type="checkbox" value="   " />   <br/>
    <input type="checkbox" value="  " />  <br/>
    </div>
    <input type="button"  id="selectAll" value="   " />
    <input type="button" id="unSelect" value="    "/>
    <input type="button" id="reverse" value="  "/>
</body>
</html>

좋은 웹페이지 즐겨찾기