0

Is there a way to get all text nodes in a HTML document? I mean something like

document.getElementsByTagName("div")

but for text nodes?

Or, do I have to walk the DOM to get them?

Leo
  • 4,136
  • 6
  • 48
  • 72
  • Yes, that seems correct, @null. Bad searching on my side. What do I do now? – Leo Apr 05 '14 at 02:19
  • @Leo delete this ques or wait for someone to make it as duplicate – Deepak Ingole Apr 05 '14 at 02:22
  • Ok, I see now I can delete it. Thanks @Pilot. I will do that since it is useless. Eh, no too late. Flagging it instead. Sorry for the noise. – Leo Apr 05 '14 at 02:24

1 Answers1

2

NodeIterator with NodeFilter.SHOW_TEXT.

https://developer.mozilla.org/en-US/docs/Web/API/NodeIterator

guest
  • 6,450
  • 30
  • 44