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;
}
浏览器打断点自己跑一下就知道啦