zoukankan      html  css  js  c++  java
  • 在项目中学习.NET的JQuery CheckBox方法(全选、取消全选、其他)

    一、在项目中遇到的CheckBox的全选和取消全选以及其他等解决方案如下:

      // 对全选和取消全选的事件    

        $("#CheckAll").click(function () {
                    var checkedOfAll = $(this).prop("checked");
                    if (checkedOfAll == true) {
                        $("input[id*='check']").prop("checked", checkedOfAll);
                    } else {
                        $("input[id*='check']").prop("checked", checkedOfAll);
                    }
                    checkIds();
                });
                // 对所有子节点添加事件
                $("td :checkbox").click(function () {
                    var checkedOfOne = $("td :checkbox:checked");
                    var checkedOfTwo = $("td :checkbox");
                    // 如果子节点全部没勾选,父节点也取消勾选  
                    if (checkedOfOne.length < checkedOfTwo.length) {
                        $("#CheckAll").prop("checked", false);
                    }
                    // 如果子节点全部选中,父节点也勾选  
                    else if (checkedOfOne.length == checkedOfTwo.length) {
                        $("#CheckAll").prop("checked", true);
                    }
                });

        //公共方法

        function checkIds() {
                var tmp = "";
                $("input[id*='check']").each(function () {
                    if ($(this).attr("checked") == true) {
                        tmp += $(this).attr("rel") + ",";
                    } else {

                    }
                });
                if (tmp != '') tmp = tmp.substr(0, tmp.length - 1);
                $("#ctl00_MainHolder_idstb").val(tmp);
            }

    二、下面的图片是自己参考的例子:

  • 相关阅读:
    使用mysqltools配置读写分离环境
    mysql group replication 主节点宕机恢复
    django ---- models继承
    django -- 对模式进行调式(pay with the api)
    django -- 多对多关系的实现
    django -- verbose_name的对数据库层面的影响
    django -- model中只有Field类型的数据才能成为数据库中的列
    django -- 为model 指定数据库名
    django -- 联合索引
    flask基础之jijia2模板使用基础(二)
  • 原文地址:https://www.cnblogs.com/Jhon-xu/p/4305341.html
Copyright © 2011-2022 走看看