题解 | #dom 节点查找#
dom 节点查找
http://www.nowcoder.com/practice/74d74be449af4c66907fe2d6961c255c
递归法找到最近的公共父节点
function commonParentNode(oNode1, oNode2) { return recur_find(oNode1.parentNode,oNode2.parentNode) function recur_find(parent1,parent2){ if(parent1.contains(oNode2)){ return parent1 } if(parent2.contains(oNode1)){ return parent2 } recur_find(parent1.parentNode,parent2.parentNode) } }