I have this dropdown menu, and all i want to do is upon firing the onmouseenter event, to change the border-left of the targets next sibling to white. So far i can address the currentTarget's border-left with ease, but i cant find a way to do the same for the next sibling. Any ideas ?
Asked
Active
Viewed 5,638 times
2 Answers
6
please try this
dojo.query(evt.currentTarget).next()[0]

Rajkamal Subramanian
- 6,884
- 4
- 52
- 69
-
1thanks a lot dude it worked like a charm and works as a cross-browser solution. I just had to place a dojo.require("dojo.NodeList-traverse"); at the top. – mfreitas Jul 26 '11 at 20:21
2
The DOM node attribute nextSibling
can be used to get the next sibling. See https://developer.mozilla.org/En/DOM/Node.nextSibling.
If you want to apply some filtering when getting next sibling, e.g. get the next sibling with a certain CSS class name, try to use dojo.query
. For example,
dojo.query(node).siblings(".myClass")
returns a node list of siblings of node
with class name myClass
.

Fu Cheng
- 3,385
- 1
- 21
- 24
-
1i think nextSibling might return textnode also. nextElementSibling will return the next sibling element node – Rajkamal Subramanian Jul 26 '11 at 10:35
-
Thanks for your reply @Alex Cheng, although rajkamal is right, nextSibling does return textnode's which requires me to check for nodeTypes to get the correct element i'm after. nextElementSibling also works but it does not work in old versions of IE (< IE9). Your research was valuable to me thanks +1 for that. – mfreitas Jul 26 '11 at 20:25