(function($) { $.fn.kk = function(method) { if ($.fn.kk.methods[method]) { return $.fn.kk.methods[method].apply(this, Array.prototype.slice.call(arguments, 1)); } else if (typeof method === 'object' || !method) { return $.fn.kk.methods.init.apply(this, arguments); } else { $.error('Method ' + method + ' does not exist'); } }; $.fn.kk.methods = { init: function(options) { return this.each(function() { $(this).addClass('bg'); }); }, value: function(val) { return this.each(function() { $(this).html(val); }); } }; })(jQuery);