Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > HTML > Javascript problems

Reply
Thread Tools

Javascript problems

 
 
Peter
Guest
Posts: n/a
 
      04-22-2006
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>

 
Reply With Quote
 
 
 
 
Jonathan N. Little
Guest
Posts: n/a
 
      04-22-2006
Peter wrote:
> I'm trying to implement an n-level horizontal menu. I'm having a
> problem. The ul tags are all id'd as "nav".


Whoa! STOP! Check the spec!

http://www.w3.org/TR/html4/struct/global.html#adef-id

id = name [CS]
This attribute assigns a name to an element. This name must be
*unique* in a document.

--
Take care,

Jonathan
-------------------
LITTLE WORKS STUDIO
http://www.LittleWorksStudio.com
 
Reply With Quote
 
 
 
 
Peter
Guest
Posts: n/a
 
      04-22-2006
thanks. Will begin to rewrite now!

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Generated JavaScript vs. Manually Created JavaScript: Which one comes first? Nathan Sokalski ASP .Net 4 11-08-2007 07:24 AM
JavaScript or not JavaScript Mark Rae ASP .Net 36 09-09-2006 01:12 PM
href="javascript:func()" vs href="#" onclick="javascript:func()" CRON HTML 24 06-20-2006 08:05 PM
Javascript -> Applet: variable reset after method call from javascript?! mcdeveloper Java 1 06-13-2006 08:34 AM
To Javascript, or not to Javascript Shane NZ Computing 5 08-30-2005 09:33 PM



Advertisments