-
Book Overview & Buying
-
Table Of Contents
jQuery 1.4 Reference Guide
By :
As discussed earlier, plug-in development is a useful technique whenever we are going to perform a task more than once. Here we will itemize some of the components that can populate a plug-in file of our own design. Our plug-ins can use any combination of the following types of jQuery enhancements.
Add a new method to all jQuery objects created with the $() function.
jQuery.fn.methodName = methodDefinition;
methodName: A label for the new method
methodDefinition: A function object to execute when .methodName() is called on a jQuery object instance
When a function needs to act on one or more DOM elements, creating a new jQuery object method is usually appropriate. Object methods have access to the matched elements referenced by the jQuery object, and can inspect or manipulate them.
When we add a method to jQuery.fn, we are actually adding it to the prototype of the jQuery object. Because of JavaScript's native prototypal inheritance...
Change the font size
Change margin width
Change background colour