HTMLInputElement inherits from HTMLElement , which in turn inherits from Element .
If an object is inherited from another object, it will have all the properties of this object.
This means that everything that expects to deal with Element can be given instead of HTMLInputElement (since HTMLInputElement has all the Element properties, but some additional ones too).
The object must be an Element , so it can sit in the DOM tree (only Node can do this, and Element inherits from Node ). It must be an Element , so it can have an id .
Only some element types have a value property that can be useful to change, so your code should also be an HTMLInputElement (or another element type with a value property), but getElementById doesn’t worry about that.
For further reading, see Prototype Programming .
source share