DIV CSS 佈局教程網

 DIV+CSS佈局教程網 >> 網頁腳本 >> JavaScript入門知識 >> jQuery入門知識 >> JQuery特效代碼 >> jqueyr判斷checkbox組的選中(示例代碼)
jqueyr判斷checkbox組的選中(示例代碼)
編輯:JQuery特效代碼     
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";
        }
XML學習教程| jQuery入門知識| AJAX入門| Dreamweaver教程| Fireworks入門知識| SEO技巧| SEO優化集錦|
Copyright © DIV+CSS佈局教程網 All Rights Reserved