Middle
What is DOM (Document Object Model)?
sobes.tech AI
Answer from AI
The DOM (Document Object Model) is a programming interface for working with HTML and XML documents. It represents the structure of a document as a tree of objects, where each node is an element, attribute, text, or other component of the document.
With the DOM, you can dynamically change the content, structure, and styles of a web page through scripts (for example, JavaScript). This allows for creating interactive and dynamic web applications.
Example: if you have an HTML element <div id="myDiv">Hello</div>, you can access this element through the DOM and change its content:
const elem = document.getElementById('myDiv');
elem.textContent = 'Hello';
Thus, the DOM is a bridge between the code and the visual representation of the document in the browser.