gaintsev
11/12/2014 - 5:14 PM

Base jQuery plugin state

Base jQuery plugin state

/*
* Plugin
*/
(function($) {
    $.fn.myPlugin = function(options) {

        // set default settings
        var settings = $.extend({
            color          : 'yellow',
            backgroundColor: '#000'
        }, options);

        // plugin body
        this.css({
            color          : settings.color,
            backgroundColor: settings.backgroundColor
        });

        return(this);

    };
})(jQuery);

/*
* Usage example
*/
$('a').myPlugin({
    color: '#000',
    backgroundColor: 'lime'
});