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.