What is HTML DOM?
- HTML DOM stands for HTML Document Object Model.
- It is a programming interface for web documents.
- It represents the structure of an HTML document as a tree of objects.
- With the HTML DOM, JavaScript can access and manipulate all elements of an HTML document.
Example: This example shows the accessing the JavaScript HTML DOM by id.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport"
content="width=device-width,
initial-scale=1.0">
<title>Accessing the JavaScript
HTML DOM by id
</title>
</head>
<body>
<h1 id="demo">This is some text.</h1>
<button onclick="changeText()">
Change Text
</button>
<script>
function changeText() {
let element = document.getElementById("demo");
element.textContent = "Text changed by JavaScript!";
}
</script>
</body>
</html>
Output:
JavaScript HTML DOM
The HTML DOM serves as a blueprint for webpages, outlining their structure and individual elements, using JavaScript it can dynamically access and modify the content, structure, and style of a webpage. We can access, modify, and delete the HTML elements via JavaScript.
Table of Content
- What is DOM?
- Features of JavaScript DOM
- What is HTML DOM?
Contact Us