We can access the specific element of any existing html page by using the method getElementById(). For accessing any element in order to refer to it must have its some unique identity. Therefore we can uniquely identify that specific element in that page.
<input id="txt" type="text" value=""/>
Description of Code:
In the following example we have created a web page into which we have defined a text input box and one button when the user clicks on the button it calls the function funcGetElement() which takes the reference to the element and takes the value of it and displays value in the alert message. Here is the full example code for getElementByIdExample.html as follows :
Input your text here to show the use of getElementById() method. Your output would like the following :