get all children as string JSDOM (node.js)

  children, html, javascript, jsdom, node.js
<html>
  <body>
    <div>
      <p>info1</p>
      <p>info2</p>
      <p><a href="https://link.com">info3</a></p>
      <p>info3</p>
    </div>
  </body>
</html>

I am doing

var p1 = dom.window.document.querySelector("div").children[0].textContent;
var p2 = dom.window.document.querySelector("div").children[1].textContent;
var p3 = dom.window.document.querySelector("div").children[2].textContent;

how can I get all children’s text with 1 method instead of doing this janky way?

Source: Ask Javascript Questions

LEAVE A COMMENT