O'Reilly logo

Learning jQuery Third Edition by Karl Swedberg, Jonathan Chaffer

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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); ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required