Return to Snippet

Revision: 22311
at January 8, 2010 16:30 by ira


Initial Code
(function($){

	$.fn.pluginName = function(params){
	
		// give the options their default value
		options = $.extend({
		
			option1: 'default text' // example option (delete)
			
		}, params);
		
		// plugin actions. Most code should go here.
		this.each(function(){ 
			
			$(this).fadeOut('slow', function(){ $(this).html(options.option1).fadeIn() }); //example action (delete and replace with your code)
			
		});
		
		return this; // keeps jquery chaining going
	
	}
	
})(jQuery);

$('p').pluginName({option1:'new text'}); // call the plugin, pass it the options

Initial URL

                                

Initial Description
Basic skeleton for a plugin.  Contains an example to show where code needs to go.

Initial Title
jQuery plugin starter code

Initial Tags
javascript, jquery

Initial Language
jQuery