checkBox 전체 선택, 전체 선택, 반선택

13234 단어
checkBox 사용:
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.7.min.js" type="text/javascript">script>

    <script type="text/javascript">

        $(function () {

            //  

            $("#btnCheckAll").bind("click", function () {

                $("[name = chkItem]:checkbox").attr("checked", true);

            });

 

            //  

            $("#btnCheckNone").bind("click", function () {

                $("[name = chkItem]:checkbox").attr("checked", false);

            });

 

            //  

            $("#btnCheckReverse").bind("click", function () {

                $("[name = chkItem]:checkbox").each(function () {

                    $(this).attr("checked", !$(this).attr("checked"));

                });

            });

 

            //  

            $("#btnSubmit").bind("click", function () {

                var result = new Array();

                $("[name = chkItem]:checkbox").each(function () {

                    if ($(this).is(":checked")) {

                        result.push($(this).attr("value"));

                    }

                });

 

                alert(result.join(","));

            });

        });

    script>

head>

<body>

    <div>

        <input name="chkItem" type="checkbox" value=" " /> 

        <input name="chkItem" type="checkbox" value=" " /> 

        <input name="chkItem" type="checkbox" value=" " /> 

        <input name="chkItem" type="checkbox" value=" " /> 

        <input name="chkItem" type="checkbox" value=" " /> 

        <input name="chkItem" type="checkbox" value=" " /> 

        <input name="chkItem" type="checkbox" value=" " /> 

    div>

    <div>

        <input id="btnCheckAll" type="button" value=" " />

        <input id="btnCheckNone" type="button" value=" " />

        <input id="btnCheckReverse" type="button" value=" " />

        <input id="btnSubmit" type="button" value=" " />

    div>

body>

html>

 
다음으로 전송:https://www.cnblogs.com/xbblogs/p/4897810.html

좋은 웹페이지 즐겨찾기