||View All MessagesBack to WebFX|
In your instance, e.nextSibling is returning a textNode not the UL element. This is because your UL element is not placed immediately to the right of your A (anchor) element, but on the next line. Between the UL and A elements is a hidden/whitespace textNode. textNodes do not have a tagName property, hence your problem. Either you can call nextSibling twice like Guilherme suggested, or use a while loop to iterate through nextSibling until a valid element node is found.
Brian R. James
From: Kenneth Solberg
Sent: Feburary 26, 2004
Consider this markup fragment:
<a href="#">Online Resources</a>
And this piece of script:
document.onclick = va_nav;
Why doesn't the alert show "UL" when I click the anchor?
Thanks in advance!