JQ监控checkbox的选中与否做出相应改变

 Html代码:

   <tr>
     <td height="90" align="center" class="color999">
       <input name="Agreements" type="checkbox" />我已认真阅读并同意遵守<a href="#" class="color-green">用户服务协议</a>
    </td>
   </tr>
   <tr>
     <td height="50" align="center">
       <input type="button" name="SureBtn" id="SureBtn" value="完成提交" class="cre-button" style="display: none" />
    </td>
    </tr>

JQ代码:

  <script>
        $(function () {
            //监控checkbox代码
            $("input[name='Agreements']").on("change", function () {
                var change = $("input[type='checkbox']").is(':checked'); //checkbox选中判断
                if (change) {

                    $("#SureBtn").css("display", "block");
                    $("#SureBtn").click(function () {
                        var str = $(" input[name='WorkYears']").val();
                        alert($("input[name='Agreements']").is(':checked'));
                    })
                } else {
                    $("#SureBtn").css("display", "none");
                    return false;
                }
            })
        })
    </script>

 


版权声明:本文为CAO11021原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。