views:

36

answers:

1

How can one select a specific sibling of a context node using jQuery? Specifically, given context node myContextNode select the sibling span with class myClass.

document.evaluate("../span[@class='myClass']",
    myContextNode, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).
    singleNodeValue;
+5  A: 

You can use .siblings() with a selector, like this:

$(myContextNode).siblings("span.myClass")
Nick Craver