jQuery实现CheckBox全选,全不选,反选代码

 //全选
        $("#selectall").bind("click", function () {
            var cb = $("#datatablename :checkbox");
            cb.attr("checked", true);
        });
        //全不选
        $("#selectnone").bind("click", function () {
            var cb = $("#datatablename :checkbox");
            cb.attr("checked", false);
        });
        //反选
        $("#selectinvert").bind("click", function () {
            var cb = $("#datatablename :checkbox");
            cb.each(function () {
                this.checked = !this.checked;
            });
        });
posted @ 2011-09-19 16:32  风一样的大叔  阅读(146)  评论(0编辑  收藏  举报