开发者

JQuery parentsUntil with element as variable not working as expected

开发者 https://www.devze.com 2023-01-22 05:08 出处:网络
My problem is best explained with examples: This works: $(startContainer).parents().each(function(index, parentNode) {

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

精彩评论

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