How to create a jQuery plug-in
This tutorial will guide you through creating your own jQuery plug-in. If you're not familiar with jQuery, check out [jQuery.org](http://www.jquery.org) and read the beginner tuts before continuing.
“The dimensions plug-in can be downloaded for free from the jQuery web site.”
We'll be creating a plug-in which allows centering of elements, not surprisingly called center().
This plug-in will use the dimensions plug-in's functions, so that plug-in is required for the jQuery one to work.
The dimensions plug-in can be downloaded for free from the jQuery web site.

As you can see there's really not much to it.
The first four lines of code are almost always the same (except for the name of the function, of course).
The reason we return this.each is because of jQuery's amazing chain-functionality which allows for multiple function-calls in a row without having to select the element over and over.
Here's an example of what I mean:
If we did not return every element from center(), fadeIn() would have nothing to work with.