JQuery parentsUntil with element as variable not working as expected
My problem is best explained with examples:
This works:
$(startContainer).parents().each(function(index, parentNode) {
if (parentNode.isSameNode(co开发者_JAVA百科mmonContainer)) 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?
The argument to parentsUntil()
is supposed to be a selector, not a node.
精彩评论