You can make your plugin customizable by accepting options.
$.fn.colourize = function(options) {
// This is one method to support default options
var style = $.extend({
color: "green",
backgroundColor: "white"
}, options);
// Set the colours on the current selection based on the option parameters
return this.css({
color: style.color,
backgroundColor: style.backgroundColor
});
};
Example usage:
$("button").colourize({
color: "orange"
});
The default value for the colour option "green" gets overridden by $.extend()
to be "orange".