DOM_Manipulation_and_DOM_Tree
DOM_Manipulation_and_DOM_Tree
Construction
1. What is DOM?
The DOM (Document Object Model) is a programming interface provided by the browser for
HTML and XML documents. It represents the page structure as a tree of objects, allowing
programming languages like JavaScript to access and manipulate the document's content,
structure, and style dynamically.
2. DOM Manipulation
DOM Manipulation refers to the process of accessing and modifying the elements, attributes,
or content of an HTML document through scripting languages (primarily JavaScript).
Example:
document.getElementById("demo").textContent = "Hello, DOM!";
DOM Tree:
Document
└── html
└── body
├── h1
│ └── "Hello"
└── p
└── "Welcome"
Conclusion
DOM Manipulation allows developers to dynamically interact with the structure and
content of a webpage using JavaScript. The DOM Tree, built during page load, represents the
document as a structured tree of nodes, enabling efficient access and modification of HTML
elements.