jqueyr判断checkbox组的选中(示例代码)


html:
复制代码 代码如下:

  <tr>
                        <td align="right">
                        </td>
                        <td align="left" colspan="3">
                            <input type="checkbox" class="checkboxListItem" name="checkItem" value="3" id="slsa_approval" />批准   
                            <input type="checkbox" class="checkboxListItem" name="checkItem" value="4" id="slsa_noApproval" />不批准
                        </td>
                    </tr>

jquery :
复制代码 代码如下:

$(function () {
    $(".checkboxListItem").change(    //教师
        function () {
            var $checkValue = $("input[name='checkItem']:checked").val();
            if ($checkValue == 3) {
                $("#slsa_approval").attr("checked", true);
                $("#slsa_noApproval").attr("checked", false);
            }
            else {
                $("#slsa_approval").attr("checked", false);
                $("#slsa_noApproval").attr("checked", true);
            }
        });
});

通过值的判断:
复制代码 代码如下:

 var checkCheckbox = $("#slsa_approval").attr("checked");
        if (checkCheckbox == true) {
            auditState = "3";
        } else {
            auditState = "4";
        }

« 
» 
快速导航

Copyright © 2016 phpStudy | 豫ICP备2021030365号-3