Creating a jQuery animation plugin

Plugins are an excellent way of packaging up functionality into an easy to deploy and share module of code that serves a specific purpose. jQuery provides the fn.extend() method precisely for this purpose, making it easy to create powerful and effective plugins that can be easily distributed and used.

There are a few guidelines that should be adhered to when creating jQuery plugins; these are as follows:

  • New methods, which are called like other jQuery methods, for example $(elements).newMethod() should be attached to the fn object, and new functions, which are used by the plugin, for example $.myFunction(), should be attached to the jQuery object
  • New methods and functions should always end in a semi-colon (;) to ...

Get jQuery 1.4 Animation Techniques Beginner's Guide now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.