js dom

来源:互联网 发布:人才结构优化措施 编辑:程序博客网 时间:2024/05/20 17:22
document.getElementById(elementId);
[element].getElementsByTagName(elmentTagName);
-----------------------------------------------------
nodeType:element,attribute,comment,text,etc(12 types)
nodeName:文本节点的nodeName为#text,元素节点的nodeName与tagName相同
nodeValue:节点的值,元素节点的nodeValue为null,文本节点的nodeValue为文本内容
------------------------------------------------------
ul=document.getElementById("eventsList");
ul.setAttribute("while", "hhe");
alert(ul.getAttribute("while"));
------------------------------------------------------
document.createElement(nodeName)
document.createTextNode('string')
node.appendChild(newNOde)
newNode=node.cloneNode(bool)
node.insertBefore(newNode,oldNode)
node.removeChild(oldNode)
node.replaceChild(newNode,oldNode)