JavaScript getElementById() Method

You are Here:

JavaScript getElementById() Method

The getElementById() method returns the element whose id attribute matches the specified string.

Note: Element IDs are required to be unique if specified, they're a useful way to get access to a specific element quickly.


HTML Online Editor
<!DOCTYPE html> <html> <body> <p id="point"></p> <script> var txt = "<strong> Hello there! </strong>"; document.getElementById("point").innerHTML = txt; </script> </body> </html>



Parameter Values

elementIDRequiredThe id name of the elements you want to get.

More Examples


HTML Online Editor
<!DOCTYPE html> <html> <body> <p id="point">I like green</p> <script> var x = document.getElementById("point"); = "green"; </script> </body> </html>


Hi Developers, we almost covered 97% of JavaScript Tutorials with examples for quick and easy learning.

We are working to cover every Single Concept in JavaScript.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author