[thelist] DOM, parentNodes and other Familial Matters
Randy Pearson
randyp at cycla.com
Fri Oct 31 12:30:55 CST 2003
There's always this:
document.getElementById('menu1_1')
Although yours might be faster--not sure.
Aside: I think ID's are supposed to be unique. Thus, you shouldn't repeat
id="active" like you have done.
-- Randy
> -----Original Message-----
> From: thelist-bounces at lists.evolt.org
> [mailto:thelist-bounces at lists.evolt.org] On Behalf Of Tom Dell'Aringa
> 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.
More information about the thelist
mailing list