[Javascript] any ideas on menu control?

Håkan Magnusson hakan at backbase.com
Sun Mar 14 05:46:08 CST 2004


Well, for siblings you have element.nextSibling/previousSibling. 
Remember that there are more than element nodes in your DOM, like text 
nodes. You will have to check to nodetype of the node you are looking at.

                        element.parentNode
                                |
element.previousSibling <-- element --> element.nextSibling
                               /
                element.firstChild -> element.firstChild.nextSibling ...

Regards,
Hakan

jsWalter wrote:
> I have this block...
> 
>   <.li>
>     <.span onclick="do_menu(this)" id='zz'>
>       <.a href="#" Xtarget="display">About</a>
>     </span>
>     <.ul class="level_two">
>       <.li class="active">
>         <.a href="../index.html" target="display">Board Members</a>
>       </li>
> 	<.li>
>         <.a href="../index.html" target="display">NYSBA Staff</a>
>       </li>
>       <.li><a href="../index.html" target="display">Members</a>
>       </li>
>     </ul>
>   </li>
> 
> I want to display the <.ul class="level_two"> block when its sibling SPAN is
> clicked.
> 
> I would also like to "unhilight" the previous SPAN and hide its sub-menu, if
> it has one. (picky picky)
> 
> For some reason, I can't seem to remember how to retrieve an object
> reference to a sibling of a given HTML element.
> 
> Can someone show me the bloody obvious?
> 
> Thanks
> 
> Walter
> 
> _______________________________________________
> Javascript mailing list
> Javascript at LaTech.edu
> https://lists.LaTech.edu/mailman/listinfo/javascript
> 
> 



More information about the Javascript mailing list