DOM Retrieving Elements By ID


Example

document.getElementById('uniqueID')

will retrieve

<div id="uniqueID"></div>

As long as an element with the given ID exists, document.getElementById will return only that element. Otherwise, it will return null.

Note: IDs must be unique. Multiple elements cannot have the same ID.