How to get text of every text node in Cheerio?

Viewed 220
<div>
  <p>Hello World!</p>
foo
</div>

I want to get only the text of the text nodes inside the div, and I can't use $('div').text() because that gives me the text of the p also.

Actually I would like to get the text of every such text node, and I hope there's something as simple as $('textNode').toArray().map((node) => $(node).text()).

0 Answers
Related