jQuery插件开发分为两种:1 类级别、2 对象级别

1、类级别

$.extend({ 
add:function(a,b){return a+b;} , 
minus:function(a,b){return a-b;} 
}); 

调用方式

var i = $.add(3,2); 
var j = $.minus(3,2); 

2、对象级别

复制代码
$.fn.extend({ 
check:function(){ 
return this.each({ 
this.checked=true; 
}); 
}, 
uncheck:function(){ 
return this.each({ 
this.checked=false; 
}); 
} 
}); 
复制代码

调用方式

$('input[type=checkbox]').check(); 
$('input[type=checkbox]').uncheck(); 

 posted on 2016-06-28 15:52  阿曜  阅读(103)  评论(0编辑  收藏  举报