Created
October 13, 2014 07:29
-
-
Save tiendq/95073e27de744ae31456 to your computer and use it in GitHub Desktop.
jQuery plugin example.
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
// 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