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

 

posted @ 2015-09-25 19:40  小小高  阅读(520)  评论(1编辑  收藏  举报