zoukankan      html  css  js  c++  java
  • 全选和全不选

    version 0.1.0:

    //调用

    var $allC = $("input.allchecked");
    var $angleC = $("div input[type='checkbox']");
    checkAll($allC, $angleC);
    });

    //全选
    function checkAll(all, ones) {
    all.live("click", function () {
    if (this.checked) {
    ones.attr({ "checked": "checked" });
    all.attr({ "checked": "checked" });
    } else {
    ones.removeAttr("checked");
    all.removeAttr("checked");
    }
    });
    ones.live("click", function () {
    if (this.checked && ones.not(":checked").length == 0) {
    all.attr({ "checked": "checked" });
    } else {
    all.removeAttr("checked");
    }
    });
    }

     

    versin 0.0.1:

    // 调用

    checkAll($("#allcheck"), $("table tbody input[type='checkbox']"));

    //全选全不选

    function checkAll(all, ones) {

        all.click(function () {

            if (this.checked) {

                $(ones).attr({ "checked": "checked" });

            } else {

                $(ones).removeAttr("checked");

            }

        });

     

        ones.click(function () {

            if (this.checked && ones.not(":checked").length == 0) {

                all.attr({ "checked": "checked" });

            } else {

                all.removeAttr("checked");

            }

        });

    }

     

     

     

  • 相关阅读:
    配置文件
    ajax
    网线颜色排序
    cs程序添加初始化加载
    后台设置gridview不换行
    js 经典正则判断 一个字符串是否包含另一个字符串
    窗体关闭事件
    oracle根据视图删除表
    (字符串)哈希
    (字符串)哈希
  • 原文地址:https://www.cnblogs.com/shenyulin/p/4399193.html
Copyright © 2011-2022 走看看