DOM (Document Object model).
1 Document: "D" in DOM
When you create a Web page and load it into a browser, the DOM is born quietly. It transforms a Web page document into a Document object.
2 object: "O" in the DOM
Three types of objects in JavaScript:
- User-defined objects (User-defined object): self-created objects
- Built-in objects (native object): Objects built into the JavaScript language, such as Array, Math, and Date
- Host object: Object provided by the browser
3 model: "M" in the DOM
The DOM represents the current page loaded into the browser window; The DOM represents a document as a tree.
4 nodes
A document is a collection of nodes
4.1 ELEMENT nodes
The atomic element node of the DOM, where elements are laid out in the document, forms the structure of the document. The name of the HTML tag is the name of the element.
4.2 Text nodes
The text node is always contained inside the element node.
4.3 Attribute nodes
The attribute node (attribute node) is used to make a more specific description of the element.
4.4 CSS
4.5 Getting elements
- getElementById: Returns an object that corresponds to an element node with the given ID attribute value: document.getElementById (ID)
- getElementsByTagName: Returns an array of objects for the element of the given label: element.getelementbytagname (TAG)
- Getelementsbyclassname: An array of objects that return the elements of the given class attribute: Element.getelementsbyclassname (Class)
5 Getting and setting properties
- GetAttribute:object.getAttribute (attribute)
- SetAttribute:object.setAttribute (attribute, value)
<dom Scripting>2:dom