Category: Other

Extending objects with JQuery.extend

You have developed a plugin and need to provide default options allowing end users to overwrite them. The solution is simple  (function($) {   $.fn.myPlugin = function(options) {        options = $.extend({            message: ‘Hello world’,            css: {                color: ‘red’            }        }, options);        return this.each(function() {            $(this).css(options.css).html(options.message);        });    };})(jQuery); In this recipe, we use the $.extend() method provided […]

Read More
Back to top