Get the contents of a element with just Javascript

Posted 2 years ago

<div id='content'>
  Something<br>
  Something else
</div>

<script>
  console.log(document.getElementById('content').textContent); // Logs pure text content (no dom elements i.e. 
) console.log(document.getElementById('content').innerHTML); // Logs all inner content, (including the
in this case) </script>

See more on textContent and innerHTML