Here is a snippet of my code:
const headings = document.getElementsByTagName("h2");
const paragraphs = document.getElementsByTagName("p");
In my HTML file, I have two h2
elements and four p
elements.
My goal is to retrieve the entire text content of each element. I attempted to do so with the following code:
const testHeading = headings[0].innerText;
Unfortunately, this approach did not yield the desired result.
If anyone can provide guidance or assistance, it would be greatly appreciated.