[BNM] ***AMENDMENT*** How do you create and array of textNode.data of all TD's on a page

Andy Smith andy.bnm at zambezi.org.uk
Tue Oct 14 20:20:19 BST 2008


2008/10/14 David Andrew <david.andrew at gmail.com>:
> I have a set of tables on a page and I want to make an array of the
> child textNodes.data of each TD.
>
> Can it be done?
>
> So far I have managed to greate an array of TD's but the only property
> I can associate with [HTMLCollection] is .length, I can't reference the
> texNodes associated with them!?!

If your HTMLCollection is called 'collection' then 'collection.length'
is the number of TD elements and 'collection[0]', 'collection[1]', etc
refer to the individual elements. If all the TDs only contain text, no
child elements, then the only child node of each TD will be a text
node that you can access with 'collection[0].firstChild' etc, and you
can get the text content with 'collection[0].firstChild.nodeValue'
etc.

Andy


More information about the BNMlist mailing list. Powered by Wessex Networks