The Undefined type has only one value, which is undefined. We don't set undefined to a value, it's usually printed by us when there is an error.
The null type is the second data type with only one value. This special value is null. The null value represents a pointer to a null object. This is why "object" is returned when the typeof operator is used to detect null.
It is a set of specifications specified by W3C, which stipulates how js scripts interact with HTML.
DOM specifies a series of standard interfaces, allowing developers to use standard methods to manipulate the structure, content, style and behavior of web pages.
What is a node? What are the node types?
In the pages of all content and objects are referred to as nodes.
The node is the most basic unit of the document, and there are many types of nodes, and constitute a complete DOM tree structure.
Common nodes: such as element nodes, attribute nodes, document nodes, comment nodes, text nodes, and so on.
Speak out how to get all the elements
Get by tag name is a collection: getElementsByTagName("Element name").
Get a single element by id: + getElementById("element name").
Get by class name is a collection: + getElementsByClassName("Element name").
selectors API: Use css selectors to select elements.
querySelector("Selector") single element
querySelectorAll("selector") a collection (nodeList object)
The difference between the old and the new method:
The elements acquired by the new method are static.
The elements acquired by the old method are dynamic.
Static/Dynamic: Whether the acquired set of elements changes with the change of the node.
How to get the html body head tag
js provides an easy way to get html body head.
document.body: Get the body element.
documemt.head: Get the head element
document.documentElement: Get html element
Compatibility Get the encapsulation of the first child element