HTML DOM Document getElementById()
HTML DOM Document getElementById() Method
The getElementById() method is used to return an element with a specified id. It returns null if the element does not exist. It is used almost every time whenever we want to read or edit an HTML element and is the most common method in HTML DOM.
If two or more elements have the same id then it will return the first.
Syntax:-
Its syntax is:- document.getElementById(elementID)
Return:-
Its return is:- element with the specified id
Further Explanation:-
Parameter | Description |
id | Required. The id value of an element. |