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;
});
});
$("#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;
});
});