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");

        }

    });

}

 

 

 

 

posted on 2015-04-07 19:38  神经质女孩  阅读(123)  评论(0编辑  收藏  举报