DOM - Document Object Model Javascript
- The Document Object Model (DOM) is a programming interface for web documents.
- Object-Oriented Representation of an HTML Document
- In short, the DOM provides a way to programmatically interact with & manipulate web pages.
- Elements such as
div, p or h1, are represented as nodes in a tree structure.
- You can access & modify elements, attributes & styles using Javascript.
- The DOM allows for dynamic interactions like responding to user inputs (clicks, key presses) & updating the page in real-time.
Example
<!DOCTYPE html>
<html>
<body>
<h1 id="title">Hello World</h1>
</body>
</html>
document.getElementByID("title").innerText = "New Title";
Why Dom is important?
- Dynamic content
- Event Handling
- Cross-language interface
- The DOM is language-agnostic, so it works not just with Javascript but other programming languages as well.
Resources