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;
}
});
});
}
使用