JavaScript Document Object
The Document object in JavaScript represents the HTML document that is displayed in the browser. It provides a number of properties and methods for accessing and manipulating different parts of the document.
Syntax
To access the Document object in JavaScript, you can use the following syntax:
document
Example
Here is an example of accessing the Document object and changing the content of an HTML element:
<!DOCTYPE html>
<html>
<head>
<title>JavaScript Document Object Example</title>
</head>
<body>
<h1 id="title">Hello World</h1>
<script>
// Access the Document object and change the content of the h1 element
document.getElementById("title").innerHTML = "Welcome!";
</script>
</body>
</html>
Output
The output of the above example will be the HTML page with the heading "Welcome!" instead of "Hello World".