Skip to content

Instantly share code, notes, and snippets.

@tiendq
Created October 13, 2014 07:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save tiendq/95073e27de744ae31456 to your computer and use it in GitHub Desktop.
Save tiendq/95073e27de744ae31456 to your computer and use it in GitHub Desktop.
jQuery plugin example.
// Author: Tien Do
(function ($) {
$.fn.redify = function(options) {
// Extend our default options with those provided.
// Note that the first argument to extend is an empty
// object – this is to keep from overriding our "defaults" object.
var settings = $.extend({}, $.fn.redify.defaults, options);
return this.css({
color: settings.color,
backgroundColor: settings.backgroundColor
});
};
// Plugin defaults – added as a property on our plugin function.
$.fn.redify.defaults = {
color: "#f00",
backgroundColor: "white"
};
}(jQuery));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment