DOM Document Object Model
The DOM Document Object model, which defines the interface for manipulating document Objects.
The DOM represents an HTML document as a family tree, using tokens such as parent, child, sibling (brother) to indicate the relationship between the members of the HOUSEHOLD.
first, the node
node is derived from the theory of network, which represents a network of connection points, The network is composed of Nodes.
The same is true for HTML documents, where a document is a collection of Nodes.
1. ELEMENT nodes
Element nodes, such as <body> <p> <div>, are elements that form the structure of the document in the layout of the Document.
2. Text node
A text node refers to the contents of an element node, but not all element nodes contain text Nodes.
3. Attribute Nodes
Elements have more or less attributes, and the function of the attribute is to make a more specific description of the Element. Attribute nodes are always included in the element Node.
second, Get the Document object
1. Queryselector () HTML5 New method to get the first element that meets the criteria by passing in a legitimate CSS selector
// returns the first div with ID test
2. Queryselectorall () HTML5 Newly added method, by passing in a legitimate CSS selector, you can get all eligible elements, return an array of objects
Example: document.queryselectorall (' div.foo ');// returns all DIV element objects with the Foo class style
Note: using the above two methods cannot find elements with Pseudo-class state, such as Queryselector (': hover ') will not get the result of the period
JavaScript Beginner Chapter _7 (DOM) to Be continued