JSFiddle - React, Tailwind, and code Playground

by Darby Rathbone

HTML

<div id="test">abc def
    
    <br />ghi <span>include me please</span>

</div>

CSS

#test {
    white-space: pre-wrap;
    display: none;
}

JavaScript

function getchildrennodes() {
  var b = [];
  b = [].slice.call(arguments);
  for(var c = 0; c < b.length; c++) {
      var d = [];
    if(b[c].hasChildNodes()) {
      b.splice.apply(b,[c+1,0].concat( [].slice.call(b[c].childNodes)))
    }
  }
  return b
}
console.log(
  getchildrennodes(document)
  .filter(
    function (e) {
      return Boolean(e.nodeValue)
    })
  .map(
    function (e) {
      return e.nodeValue;
    })
  .join(''));