页面的checkbox框的全选与反选
if (typeof jQuery == 'undefined') {
alert("请先导入jQuery");
} else {
jQuery.extend({
quan_fan: quan_fan
});
}
function quan_fan(all, other) {
/// <summary>
/// 全选,反选
/// </summary>
/// <param name="all">全选(按钮(checkbox))JQuery对象</param>
/// <param name="other">其它(按钮(checkbox))JQuery对象</param>
all.click(function () {
if (all[0].checked == true) {
other.each(function () {
this.checked = true;
});
}
else {
other.each(function () {
this.checked = false;
});
}
});
other.each(function () {
$(this).click(function () {
if (this.checked == false) {
all[0].checked = false;
}
});
});
}
使用
![](data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAR0AAABbCAIAAADBfsbpAAAJ2UlEQVR4nO2dS47cNhCGdQlvdR4dR0fwHXSErLPULYxxjECxk8nYcB62YTvAIAGmYcfBZKFXFatIkWxKYqv/H8KgR02VKKk+VoktUsVjUhVPC8+VoYUh6IKU0olDOTkfQgjKU7txVTwt5FehEEJQnoKzQlB6gSsISi9wBUHpVXz8+DcW2/L6tx/lUhSFXLl7VbFktYAr1wKusMQtq+SBRXGQ9PK3dz/RpSiK/m//gS571xTKS+kBKIiSG49WXJUkVJQucAXZlNj1e8elf3PQVBNwBW2jFbnKR9H1kVBJwMAVJLVWHuhfcipPNzSMGFmcusniLoySPjbBFRSntfotFtEysIlY6Z/dyQKeNsEVFKcV+wMXI4n8rK6c/rWxFMGVp01wBcVpt36LIK5kgfO58rEJrqA4bcGVmhaenweqphy1itg7+gOhOK34+5WxxlFSFpYZmiq3fcdePG2CKyhOWTxvEVp+M+F5CyhO+zu0GkzOsZPK4KPgSt5WgStIFZ67dS147hZL3AKuXIvKlbrsXlUsWS3754EXp+9fvZPL3pWC8hK4gqD0SsNV6Axn37799/rNh+cv7p7d3GLBsvvy/MXd7d27r1+/JcHhMQlXEdNrvn7z4f37v06n0wME5aFPn+9f/fJHhPPr/h9qSDXtuXLS8xd3gArKTc9ubpP5f4ShZaNLc2g+u7nd+xxCkClwBUHpZXBlm5J5Wqi3G4XP4ir6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