开发者

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜