12.9. Customizing jQuery

You can add your own functions to the jQuery library. For example, to create a simple function that will pop up an alert box, you can do so with the following code:

//don't use $ alias in case user overrides it
jQuery.fn.say = function (message) {
    alert("jQuery says " + message);

    return this;
}

You can then call the new function with the following code:

$.fn.say("hello").say("good bye");

And there is, of course, no reason why you couldn't write a new effects function and use it as part of a chain of effects.

For more information, please refer to http://docs.jquery.com/Plugins/Authoring.

Get Introducing .NET 4.0: with Visual Studio 2010 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.