Copyright © tutorialspoint.com

Prototype extend() Method

previous next


Advertisements

This method extends element with all of the methods contained in Element.Methods and Element.Methods.Simulated.

If element is an input, textarea or select tag, it will also be extended with the methods from Form.Element.Methods.

If it is a form tag, it will also be extended with Form.Methods.

Syntax:

element.extend();

Return Value:

Example:

By extending an element with Prototype's custom methods, we can achieve that syntactic sugar and ease of use we all crave for. For example, you can do the following with an extended element:

element.update('hello world');

And since most methods of Element return the element they are applied to, you can chain methods like so:

element.update('hello world').addClassName('greeting');

Note that all of the elements returned by Element methods are extended (yes even for methods like Element.siblings which return arrays of elements) and Prototype's flagship utility methods $() and $$() obviously also return extended elements.


previous next

Copyright © tutorialspoint.com