The DOM in JavaScript means the Document Object Model. It is the browser’s tree-like representation of an HTML page, and JavaScript uses it to read, change, add, or remove elements on the page
Simple idea
Think of HTML as the page structure, and the DOM as the live version of that page inside the browser. JavaScript talks to the DOM to make websites interactive, such as changing text, styles, or reacting to clicks
<p id="demo">Hello</p>
<button onclick="changeText()">Click</button>
<script>
function changeText() {
document.getElementById("demo").innerHTML = "Hi Raja!";
}
</script>
Here, document.getElementById("demo") finds the paragraph, and innerHTML changes its content
What you can do with DOM
Select elements
Change text or HTML
Update CSS styles
Add or remove elements
Handle events like click, input, or submit

Top comments (1)
Highly informative