Plugin - Basic jQuery Plugin
by alekskorovin
HTML
<div>Lorem Dodlorem</div>
<!-- http://learn.jquery.com/plugins/basic-plugin-creation/ -->
CSS
body {
background: #000;
}
JavaScript
$.fn.greenify = function( options ) {
// This is the easiest way to have default options.
var settings = $.extend({
// These are the defaults.
color: "#556b2f",
backgroundColor: "white"
}, options );
// Greenify the collection based on the settings variable.
return this.css({
color: settings.color,
backgroundColor: settings.backgroundColor
});
};
$( "div" ).greenify({
color: "orange",
backgroundColor: 'green'
});