Return to Snippet

Revision: 21882
at December 22, 2009 15:41 by magicrebirth


Initial Code
jQuery('div#message').addClass(
	'borderfade'
).animate({
   'borderWidth': '+10px'
}, 1000).fadeOut();


// Can be 'packaged' as:

jQuery.fn.dumbBorderFade = function() {
    return this.addClass(
        'borderfade'
    ).animate({
       'borderWidth': '+10px'
    }, 1000).fadeOut();
};

// Now we can apply it to an element like so:

jQuery('div#message').dumbBorderFade();

Initial URL

                                

Initial Description
the plugin model in JQuery takes advantage of JavaScript’s prototype inheritance and makes it trivially easy to add new chainable methods

Initial Title
JQuery: package stuff into a plugin

Initial Tags
plugin

Initial Language
jQuery