DOM Document

The DOM document will be holding all the objects, properties, events and methods to access the HTML document.
In javascript, we use document object to access and manipulate the HTML.

Example

<html>
<head>
    <title>JavaScript getElementById() Method</title>
</head>
<body>
    <p id="message">ReadersBuddy</p>
</body>
<script>
   const para = document.getElementById('message');
   console.log(para);
</script>
</html>

Output

<p id="message">ReadersBuddy</p>

In the above example, we have used getElementById method of document to get the para element with id message.

The document object has many other functions to manipulate the HTML elements.
We shall see in our next tutorials.


Most Read