Created
October 5, 2011 05:44
-
-
Save jrob00/1263740 to your computer and use it in GitHub Desktop.
jQuery Plugin Template
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
* jquery.pluginTemplate.js | |
* | |
*/ | |
(function( $ ){ | |
$.fn.pluginName = function(options) { | |
// there's no need to do $(this) because | |
// "this" is already a jquery object | |
var settings = { | |
'setting1' : 'val1', | |
'setting2' : 'val2' | |
}; | |
// Maintain chainability... | |
return this.each(function() { | |
// If options exist, merge them | |
// with our default settings | |
if ( options ) { | |
$.extend( settings, options ); | |
} | |
// plugin code here | |
}); // END: return this.each(function() { (which maintains chainability) | |
}; // END: $.fn.pluginName = function() { | |
})( jQuery ); // END: (function( $ ){ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment