JQuery: package stuff into a plugin
// the plugin model in JQuery takes advantage of JavaScript’s prototype inheritance and makes it trivially easy to add new chainable methods
Can be 'packaged' as:
Now we can apply it to an element like so:
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();