getElementsByTagName() equivalent for textNodes

Posted by levik on Stack Overflow See other posts from Stack Overflow or by levik
Published on 2010-04-05T16:58:36Z Indexed on 2012/07/06 3:16 UTC
Read the original article Hit count: 164

Filed under:
|
|
|

Is there any way to get the collection of all textNode objects within a document?

getElementsByTagName() works great for Elements, but textNodes are not Elements.

Update: I realize this can be accomplished by walking the DOM - as many below suggest. I know how to write a DOM-walker function that looks at every node in the document. I was hoping there was some browser-native way to do it. After all it's a little strange that I can get all the <input>s with a single built-in call, but not all textNodes.

© Stack Overflow or respective owner

Related posts about JavaScript

Related posts about dom