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.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.188.119.81