Note: Returns null if no elements with the specified ID exists.
This method used almost every time you want to manipulate, or get info from, an element on your document. In the example, we are using it only gets an element.
<!DOCTYPE html> <html> <body> <p id="demo">Hello </p> <script> var txt = document.getElementById("demo"); alert(txt); </script> </body> </html>
Do comment if you have any doubts and suggestion on this topic.
Note: The All JS Examples codes are tested on the Firefox browser and the Chrome browser.
OS: Windows 10
Code: HTML 5 Version
Degree in Computer Science and Engineer: App Developer and has multiple Programming languages experience. Enthusiasm for technology & like learning technical.