search

Home  >  Q&A  >  body text

Difference between createElement and crateTextNode - Stack Overflow

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?

巴扎黑巴扎黑2771 days ago646

reply all(2)I'll reply

  • 漂亮男人

    漂亮男人2017-05-16 13:39:20

    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.

    reply
    0
  • PHP中文网

    PHP中文网2017-05-16 13:39:20

    Create element nodes, create text nodes

    reply
    0
  • Cancelreply