Getting started with jquery-plugins – Supporting options with defaults

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".

if you want to reproduce, please indicate the source:
Getting started with jquery-plugins – Supporting options with defaults - CodeDay