Method parameters
In Chapter 7, Using Plugins, we saw some plugins that can be fine-tuned to do exactly what we want through the use of parameters. We saw that a cleverly-constructed plugin helps us by providing sensible defaults that can be independently overridden. When we make our own plugins, we should keep the user in mind the same way.
As our example, we'll start with a plugin method that provides a shadow on an element. This can be done with various advanced CSS techniques, but here we'll use a more brute force approach: we will create a number of elements that are partially transparent, overlaid in different positions on the page, as follows:
(function($) { $.fn.shadow = function() { return this.each(function() { var $originalElement = $(this); for (var i = 0; i < 5; i++) { $originalElement .clone() .css({ position: 'absolute', left: $originalElement.offset().left + i, top: $originalElement.offset...