jquery-fn

常规做法

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
(function($){
$.fn.method = function(method){
if(methods[method]){
return methods[method].apply(this,Array.prototype.slice.call(arguments,1));
}else if(typeof method === 'object' || !method){
return methods.init.apply(this,arguments);
}else{
$.error('..');
return false;
}
};

var methods = {
init: function(){},
destroy: function () {},
data: function(){}

};
})(jQuery);