There are several types of nodes in the DOM, common
1. Documentation node (document, unique)
2. Element nodes (those tags div,p, etc.)
3. Attribute node (class,src this)
4. Text node (text inserted inside p,div)
Other..
Where Element.nodevalue is the value of the node, where the attribute node and text node are value, and the element node has no value.
innerHTML returns all child nodes of the node and their values as a string
As an example:
<p id="example" title="texts"> 这是一段文本 <span></span></p>
VarP=Document.getElementById(' Example ');P.NodeValueNull,p is an element node, so nodevalue is nullPgetattributenode ( ' id ' ). NodeValue //example, here Gets the attribute node to the id attribute of P, NodeValue is its attribute value p.childnodes[0]. NodeValue /* " This is a text " P is a two child node, and the inserted text is still a node, although it is not labeled. */p . innerhtml/* " This is a text < Span></span> " here innerHTML returns the various values contained in all of the nodes contained in P, in the form of strings. */
InnerHTML nodevalue The difference