/*扩展jQuery对象方法,方法使用时需对象调用*/
(function($){
$.fn.extend({
checkAll:function(){
this.prop({
checked:true
})
},
noAll:function(){
this.prop({
checked:false
})
},
singleCheck(){
this.each(function() {
this.checked=! this.checked
});
}
})
})(jQuery)
/*调用*/
$('#btn1').click(function(){
$('.item').checkAll()
})
/*扩展jQuery全局方法,直接使用jQuery/$调用*/
(function ($) {
$.extend({
min:function(a,b){
return a<b? a:b
}
})
})(jQuery);
/*调用*/
$.min(1,2)