en.javascript.info/2-ui/1-document/07-modifying-document/1-createtextnode-vs-innerhtml/solution.md
Ilya Kantor dbf5c7587c minor
2017-03-13 00:21:00 +03:00

356 B

Answer: 1 and 3.

Both commands result in adding the text "as text" into the elem.

Here's an example:

<div id="elem1"></div>
<div id="elem2"></div>
<div id="elem3"></div>
<script>
  let text = '<b>text</b>';

  elem1.append(document.createTextNode(text));
  elem2.textContent = text;
  elem3.innerHTML = text;
</script>