get a div text content and store in a variable js

JavaScript
<div id="test">
  Some <span class="foo">sample</span> text.
</div>
Source

Also in JavaScript: