views:

21

answers:

1

My problem is best explained with examples:

This works:

$(startContainer).parents().each(function(index, parentNode) {
    if (parentNode.isSameNode(commonContainer)) return false;
    console.log("start vert struc: " + parentNode.nodeName);
});

While, this does not work:

$(startContainer).parentsUntil(commonContainer).each(function(index, parentNode) {
    console.log("start vert struc: " + parentNode.nodeName);
});

Basically, the second version should work too as far as I know, but it doesn't. It simply does not stop when commonContainer hits, yet the first version does. Why is this?

+2  A: 

The argument to parentsUntil() is supposed to be a selector, not a node.

Pointy
+1, [jQuery API reference for: `parentsUntil()`](http://api.jquery.com/parentsUntil/).
David Thomas
Ah, I was confused by your answer to my first question. I figured this meant that one can use nodes as selectors.
Tom
Oh sorry. It's sometimes important to double-check with me because I can get surprisingly muddled :-)
Pointy