Returns the element whose ID is specified.
Syntaxelement = document.getElementById(id);
element is an object.
id is a string representing the unique id of the element being sought.
getElementById is an absolute mainstay of the DOM. One of the most important notions in DOM programming is that elements be identified uniquely so that they can be grabbed and manipulated.
If there is no element with the given ID, this function returns NULL. Note also that the DOM implementation must have information that says which attributes are of type ID. Attributes with the name "ID" are not of type ID unless so defined. Implementations that do not know whether attributes are of type ID or not are expected to return null.
getElementById was introduced in DOM Level 2.