Answers for "find element that has certain text javascript"

0

find element that has certain text javascript

for (const a of document.querySelectorAll("a")) {
  if (a.textContent.includes("your search term")) {
    console.log(a.textContent)
  }
}

Or with a separate filter:

[...document.querySelectorAll("a")]
   .filter(a => a.textContent.includes("your search term"))
   .forEach(a => console.log(a.textContent))
Posted by: Guest on October-28-2021

Code answers related to "find element that has certain text javascript"

Code answers related to "Javascript"

Browse Popular Code Answers by Language