(1)创建新节点
createDocumentFragment() //创建一个DOM片段
createElement() //创建一个具体的元素
createTextNode() //创建一个文本节点
(2)添加、移除、替换、插入
appendChild(node)
removeChild(node)
replaceChild(new,old)
insertBefore(new,old)
(3)查找
getElementById();
getElementsByName();
getElementsByTagName();
getElementsByClassName();
querySelector();
querySelectorAll();
(4)属性操作
getAttribute(key);
setAttribute(key, value);
hasAttribute(key);
removeAttribute(key);
本文深入探讨了DOM节点的创建、添加、移除、替换和插入等操作,还讲解了如何查找DOM节点以及进行属性操作。重点针对前端开发中的JavaScript和HTML应用,在Chrome环境下进行了实践阐述。
574

被折叠的 条评论
为什么被折叠?



