PDA

View Full Version : accessing nested div tags


w0lf42
08-12-2003, 07:18 PM
I am trying to access all div tags in side of the main one.

<div id="adultRegGroup"><div id="adultRegDef">blah</div><div id="adultRegUsername">bleh</div></div>

I can access each item one at a time, but I was wondering if there is something that will allow me to access them all at once.

Jon Hanlon
08-12-2003, 07:44 PM
In IE you can use the all collection, as in adultRegGroup.all[0] etc.

For IE you can also use the children collection, see http://msdn.microsoft.com/workshop/author/dhtml/reference/collections/children.asp

For IE and NS you can use the childNodes collection.
There's a good tutorial here: http://www.siteexperts.com/tips/contents/ts16/Demo.asp

Note that with all methods you must get the children, then the children's children then ... etc. That is, there is no family tree or descendants collection.

w0lf42
08-13-2003, 12:43 PM
Thanks, very informative.