Prototype - extend() Method
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.
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 −
And since most methods of Element return the element they are applied to, you can chain methods like so −
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.