Difference between createElement and crateTextNode - Stack Overflow
巴扎黑
巴扎黑 2017-05-16 13:37:20
0
2
634

A question I encountered during the interview a few days ago. My answer is one to create the label and the other to create the text content. But the answer the interviewer wants is not this, so what direction should I think about?

巴扎黑
巴扎黑

reply all(2)
漂亮男人

Think about the composition and characteristics of nodes in the Dom tree structure:

  1. Node is the root node, and both ElementNode and TextNode inherit from it.

  2. ElementNode corresponds to the tag form, such as , it can have its own attributes: such as href, title, etc. There will also be child elements, such as another Element or Text

  3. TextNode, as the name suggests, is a text node. It is expressed in the form of text. It does not have child nodes and has no additional attributes.

Ty80

Create element nodes, create text nodes

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template