• 在aspx页面的checkbox取值验证


    在做项目的时候遇到了一个选择性的问题,之前都可以用$("#id").checked,但是不知道为什么现在不可以了,只能if($(this).is(":checked")

    <script type="text/javascript">
            function Edit() {
                var id = "";
                var count = 0;
                $("input[name='checkboxItem']").each(function () {
                    if ($(this).is(":checked")) {
                        id += $(this).val() + ",";
                        count += 1;
                    }
                });
                if (count == 0) {
                    alert("请选择操作记录");
                    return false;
                }
                if (count != 1) {
                    alert("每次只能选择一条记录");
                    return false;
                }
                window.location.href = "/Member/AddressOperate?guid=" + id;
            }
        </script>

    注意:

      这里的if($(this).is(":checked")是绝对有效的,有些时候可以用if($("# 此时控件id部分").val(),取值

    aspx页面:

      <tr><input name="checkboxItem" value='<%# Eval("Guid") %>' type="checkbox" /></tr>

      <tr><input id="checkboxAll" onclick="javascript:SelectAllCheckboxes(this);" type="checkbox" /></tr>

  • 相关阅读:
    node基础和express服务器框架知识点总结
    Nacos配置服务原理
    Queue-PriorityQueue源码解析
    Mysql存储结构
    Mybatis处理动态占位符实现
    通过ThreadPoolExecutor源码分析线程池实现原理
    jdk8函数接口
    Logback源码分析
    Spring注解Component原理源码解析
    ApplicationListener原理分析
  • 原文地址:https://www.cnblogs.com/JeffController/p/3982814.html
Copyright © 2020-2023  润新知