extend :: Element |
This is where the magic happens!
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.
If you want to know more about how Prototype extends the DOM, jump to this article. |
Prototype API 1.5.0 - prototypejs.org