[thelist] DOM, parentNodes and other Familial Matters

Tom Dell'Aringa pixelmech at yahoo.com
Fri Oct 31 09:08:13 CST 2003


Heyo,

I have this code snippet:

<div id="menu1_1">
 <ul id="ulFoo">
   <li id="active"><a href="/link">subItem one</a></li>
   <li id="active"><a href="/link">subItem two</a></li>
   ...
   <li id="active"><a href="/link">subItem ten</a></li>
 </ul>
</div>

What I want to do is reference the ID of the DIV from EACH anchor in
the LIs. 

This works:

this.parentNode.parentNode.parentNode

Giving me a valid reference to the DIV. According to the new lovely
quirksmode.org DOM charts (hat tip, ppk) parentNode is compatable
with all the modern browsers I'm concerned with.

Only question is, is there a better way to grab the reference? I'm
not concerned about the structure of the list/div relationship
changing and ruining the path to the div, I know it won't change so
that is not a concern.

Tom 

=====
http://www.pixelmech.com/ :: Web Development Services
http://www.DMXzone.com/ :: JavaScript Author / Every Friday!
http://www.thywordistruth.net/ :: Eternal Life

"I'll ho ho and ha ha you!" (Daffy Duck)


More information about the thelist mailing list