Skip to content

Instantly share code, notes, and snippets.

@rmurphey
Created June 13, 2010 15:39
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rmurphey/436754 to your computer and use it in GitHub Desktop.
Save rmurphey/436754 to your computer and use it in GitHub Desktop.
$.fn.myPlugin = function(args) {
// set defaults for the plugin
var defaults = {
foo : 'bar'
},
// override those defaults with user-provided args
settings = $.extend(defaults, args),
// define functions for stuff you'll do a lot
myFunction = function() {
// do stuff
};
// return the element(s) the plugin was called on,
// after doing stuff to them
return this.each(function() {
// you can use any of the variables you defined above here
});
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment