What is DOM
At a basic level, the Document Object Model (DOM) is an only API that represents a document as a tree structure and allows you to manipulate this document. Every object in DOM represents a particular part of the page document, also called as node. There are family tree relations between nodes. One node can have ancestors, descendants, and siblings. It enables convenient navigation through the node tree.
There are 4 main types of node: element, text, comment and attribute.
- set CSS styles, change existing ones;
- select and modify any element on the page;
- retrieve any element and change its content;
- create and remove any element, attribute;
- listen and react to any event on the page;
- and much more!