JSFiddle - React, Tailwind, and code Playground

by sandro_paganotti

HTML

<div>
  Hello
  <b>Some Text</b>
</div>

JavaScript

const nodes = Array.from(document.querySelector('div').childNodes);
const text = nodes.map(t => 
	t.nodeType == Node.TEXT_NODE 
  	? t.textContent 
    : ''
);

console.log(text.join(''));