Important FAQ
The Document Object Model (DOM) is a programming interface for web documents, such as HTML or XML files. It represents the structure of a document as a tree of objects, where each node corresponds to a part of the document (like an element, attribute, or piece of text).
There are many ways to select an element:
- 1.getElementById()
- 2.getElementsByClassName()
- 3.getElementsByTagName()
- 4.querySelector()
- 5.querySelectorAll()
Event delegation is a technique in the DOM where instead of attaching event listeners to multiple child elements individually, a single event listener is attached to a parent element to handle events triggered by its child elements. The parent can catch events as they "bubble up" from the children, thanks to event propagation (specifically, the bubbling phase).
There are many ways to manipulate an element's attributes and styles using the DOM:
- 1.setAttribute()
- 2.getAttribute()
- 3.removeAttribute()