/*
@see $("#checkall").controlCheckBox({chname:'checkProduct'});
*/
(function(jQuery){
$.fn.controlCheckBox = function(options){
var defaults = {
chname: "checkname[]"
};
var options = $.extend(defaults, options);
var $obj = $(this);
$obj.click(function(){
if (this.checked) {
$("input[name='" + options.chname + "']").attr("checked", true);
}
else {
$("input[name='" + options.chname + "']").removeAttr("checked");
}
});
$("input[name='" + options.chname + "']").click(function(){
if ($("input[name='" + options.chname + "']").filter(":checked").length == $("input[name='" + options.chname + "']").length) {
$obj.attr("checked", true);
}
else {
$obj.removeAttr("checked");
}
})
}
})(jQuery);
全选插件
最新推荐文章于 2023-05-10 16:50:36 发布