Jquery的插件开发,试了一下,还是挺简单的。 http://docs.jquery.com/Plugins/Authoring [How to write jQuery plugin.](http://www.easyjquery.com/jquery-plugins/how-to-write- jquery-plugin) http://mattberseth.com/blog/2008/06/glowbuttons_writing_my_first_j.html 乱写的,没意义代码
(function($){
$.test = {
log : function(str){
console.log(str);
},
now : function(){
console.log(new Date());
},
demo : function(option){
option = $.extend({
size : 100,
width : 40
}, option);
this.log(option);
}
};
$.fn.xx = function(){
return this.each(function(){
console.log(this.className);
});
};
})(jQuery);
html中:
$(function(){
$.test.log('aaaa');
$.test.now();
$.test.demo({size:23});
$('div').xx();
});