Javascript problems

P

Peter

I'm trying to implement an n-level horizontal menu. I'm having a
problem. The ul tags are all id'd as "nav". If I go more than 1 level
deep I can't seem locate the ul tag using Javascript. I know that may
not be the best way to put it so I'll throw some code down. Where text
is "London" is where I can't get to in the DOM using Javascript.
Ideally, I'd like to make a recursive Javascript function to find and
appropriately handle each node, no matter how nested the lists become.
Any advice would be appreciated.

<ul id="nav">
<li><a href="#">Home</a></li>
<li><a href="#">About</a>
<ul id="nav">
<li><a href="#">History</a></li>
<li><a href="#">Team</a></li>
<li><a href="#">Offices</a></li>
</ul>
</li>
<li><a href="#">Services</a>
<ul id="nav">
<li><a href="#">Web Design</a></li>
<li><a href="#">Internet
Marketing</a></li>
<li><a href="#">Hosting</a></li>
<li><a href="#">Domain Names</a></li>
<li><a href="#">Broadband</a></li>
</ul>
</li>
<li><a href="#">Contact Us</a>
<ul id="nav">
<li><a href="#">United Kingdom</a>
<ul id="nav"><li><a href="#">London</a></li></ul>
</li>
<li><a href="#">France</a></li>
<li><a href="#">USA</a></li>
<li><a href="#">Australia</a></li>
</ul>
</li>
</ul>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,768
Messages
2,569,575
Members
45,053
Latest member
billing-software

Latest Threads

Top