innerText and textContent

check the differences between innerText and textContent

by Ouyang Chao

HTML

<div id="foo">
  <div>Hello</div><div>,World</div>
</div>
<hr/>
<p id = "p1">
</p>
<p id = "p2">
</p>
<p id = "p3">
</p>

JavaScript

const foo = document.getElementById('foo');
const p1 = document.getElementById('p1');
const p2 = document.getElementById('p2');
const p3 = document.getElementById('p3');

p1.innerHTML = foo.innerHTML;
p2.innerHTML = foo.innerText;
p3.innerHTML = foo.textContent;