Skip to content

Instantly share code, notes, and snippets.

@jrob00
Created October 5, 2011 05:44
Show Gist options
  • Save jrob00/1263740 to your computer and use it in GitHub Desktop.
Save jrob00/1263740 to your computer and use it in GitHub Desktop.
jQuery Plugin Template
/*
* 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