问答详情
源自:1-3 遍历祖先

这些代码看不懂什么意思?

function parentsUntil(elem, filter) {

  var matched = [],

    until,

    truncate = filter !== undefined;

  while ((elem = elem['parentNode']) && elem.nodeType !== 9) {

    if (elem.nodeType === 1) {

      if (truncate) {

        if(elem.nodeName.toLowerCase() ==filter){

          break;

        }

      }

      matched.push(elem);

    }

  }

  return matched;

}


提问者:慕先生9164688 2019-03-27 17:32

个回答

  • Yvie
    2020-08-03 10:38:18

    浏览器打断点自己跑一下就知道啦