我
DOM 操作——怎样添加、移除、移动、复制、创建和查找节点?
难度:
(1)创建新节点
js
createDocumentFragment(node);
createElement(node);
createTextNode(text);
(2)添加、移除、替换、插入
js
appendChild(node)
removeChild(node)
replaceChild(new,old)
insertBefore(new,old)
(3)查找
js
getElementById();
getElementsByName();
getElementsByTagName();
getElementsByClassName();
querySelector();
querySelectorAll();
(4)属性操作
js
getAttribute(key);
setAttribute(key, value);
hasAttribute(key);
removeAttribute(key);