/ Published in: jQuery

Expand |
Embed | Plain Text
Copy this code and paste it in your HTML
(function( $ ){ // Default options var defaults = { // OPTIONS // ... }; var methods = { init : function( options ) { // Merge defaults with user options options = $.extend({}, defaults, options); // Return jQuery object to maintain chainability return this.each(function() { var $this = $(this); }); }, method2 : function( ) { // Return jQuery object to maintain chainability return this.each(function() { var $this = $(this); }); }, method3 : function( ) { // Return jQuery object to maintain chainability return this.each(function() { var $this = $(this); }); }, method4 : function( options ) { // Merge defaults with user options var options = $.extend(defaults, options); // Return jQuery object to maintain chainability return this.each(function() { var $this = $(this); }); } }; $.fn.PLUGINNAME= function( method ) { // Method calling logic 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( 'Method ' + method + ' does not exist on jQuery.PLUGINNAME' ); } }; })( jQuery );
Comments
