🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
## jQuery.fn.extend(object) 概述:扩展 jQuery 元素集来提供新的方法(通常用来制作插件)。 * object:用来扩充 jQuery 对象。 ~~~ // 增加两个插件方法。 jQuery.fn.extend({ check: function() { return this.each(function() { this.checked = true; }); }, uncheck: function() { return this.each(function() { this.checked = false; }); } }); $("input[type=checkbox]").check(); $("input[type=radio]").uncheck(); ~~~ ## jQuery.extend(object) 概述:扩展 jQuery 对象本身。 * object:用以扩展 jQuery 对象 ~~~ // 在 jQuery 命名空间上增加两个函数。 jQuery.extend({ min: function(a, b) { return a < b ? a : b; }, max: function(a, b) { return a > b ? a : b; } }); jQuery.min(2,3); // => 2 jQuery.max(4,5); // => ~~~