www.gusucode.com > baigo CMS PHP开源网站管理系统 v1.2.2源码程序 > baigocms_v1.2.2/bg_static/js/baigoCheckall/baigoCheckall.min.js

    /*
v1.0.1 jQuery baigoCheckall plugin 表单全选插件
(c) 2016 baigo studio - http://www.baigo.net/jquery/baigocheckall.html
License: http://www.opensource.org/licenses/mit-license.php
*/
(function($){$.fn.baigoCheckall=function(){"use strict";var thisForm=$(this);$(thisForm).find(":checkbox").click(function(){var _child=$(this).attr("id");var _parent=$(this).data("parent");child_check(_child);parent_check(_parent);});var parent_check=function(_parent){var _parent_num=$(thisForm).find("#"+_parent).size();if(_parent_num>0){var _brother_num=$(thisForm).find("[data-parent='"+_parent+"']").size();var _brother_checked_num=$(thisForm).find("[data-parent='"+_parent+"']:checked").size();if(_brother_num>0&&_brother_checked_num<_brother_num){$(thisForm).find("#"+_parent).removeAttr("checked");}else{$(thisForm).find("#"+_parent).prop("checked","checked");}
var _parent_this=$(thisForm).find("#"+_parent).data("parent");parent_check(_parent_this);}};var child_check=function(_child){var _child_obj=$(thisForm).find("[data-parent="+_child+"]");var _checked=$(thisForm).find("#"+_child).prop("checked");if(_child_obj){_child_obj.each(function(){var _disabled=$(this).attr("disabled");if(_checked){if(_disabled){$(this).removeAttr("checked");}else{$(this).prop("checked","checked");}}else{$(this).removeAttr("checked");}
var _child_this=$(this).attr("id");child_check(_child_this);});}};};})(jQuery);