题解 | #dom 节点查找#

https://www.nowcoder.com/practice/74d74be449af4c66907fe2d6961c255c

递归的思路:有唯一的解,而且每一次的解决方案是相同的

获取的DOM节点
//获取元素节点
document.getElementById()
document.getElementByTagName()
document.getElementByName()
document.querySelector()
document.querySelectorAll()
document.body
document.documentElement
//获取子节点
d.childNodes
d.children
d.firstChild
d.lastChild
d.firstElementChild
//获取父亲和兄弟
d.parentNode
d.previousSibling
d.nextSibing
//增加节点
document.createElement()
document.createTextNode()
//修改节点
parent.insertBefore(new,old)
parent.replaceChild(new,old)
parent.removeChild()
//添加节点
d.appendChild()




function  compareParent(Node1,Node2){
    let parentNode1=Node1.parentNode
    let patentNode2=Node2.parentNode
    if(parentNode1===parentNode2){
        return parentNode1
    }else{
        compareparent(parentNode1,parentNode2)
    }
}



全部评论

相关推荐

不愿透露姓名的神秘牛友
07-11 17:10
什么素质,我请问呢,要掉小珍珠了。。。又憋屈又生气
苍蓝星上艾露:给它们能的,一群dinner牛马挥刀向更弱者罢了。我写的开源求职AI co-pilot工具,优化你的简历,找到你匹配的岗位,定制你的简历,并让你做好面试准备https://github.com/weicanie/prisma-ai
点赞 评论 收藏
分享
不愿透露姓名的神秘牛友
昨天 17:24
点赞 评论 收藏
分享
醉蟀:你不干有的是人干
点赞 评论 收藏
分享
Lorn的意义:你这标个前端是想找全栈吗?而且项目确实没什么含金量,技术栈太少了,边沉淀边找吧 现在学院本想就业好一点四年至少得高三模式两年加油吧
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务