JavaScript document.getElementById is the most useful method of the JavaScript DOM document object that allows you to access the HTML elements by their "id". In HTML you can set the "id" attribute of different HTML elements that must be unique for each tag. getElementById method will return the HTML object based on "id" passed to the method that further provides various properties and methods to dynamically manipulate the HTML objects.
Try the sample code below to learn and practice the document.getElementById method functionality: