Closed mknee40 closed 2 years ago
I can't figure out how to just extract only the text from the element.
For example:
root.getElementsByTagName("p").map((elm) => { console.log(elm.text()) });
throws an error TypeError: elm.text is not a function and the below returns the HTML elements in the child as a string e.g. "text text text <a href="">text</a>":
TypeError: elm.text is not a function
"text text text <a href="">text</a>"
root.getElementsByTagName("p").map((elm) => { console.log(elm.toString()) });
What I want is to extract only the text from the element.
.innerText or .textContent
I can't figure out how to just extract only the text from the element.
For example:
throws an error
TypeError: elm.text is not a function
and the below returns the HTML elements in the child as a string e.g."text text text <a href="">text</a>"
:What I want is to extract only the text from the element.