1.访问文档中的元素
document.getElementById("id"):获取给定的id元素,并将其作为对象。document.getElementByTagName("tagname"):获取所有便签名为tagname的元素,并把它
保存在一个类似数组的列表中。
node.getAttribute("attribute"):获取属性attribute的值。
node.setAttribute("attribute","value"):设置属性名为attribute的值为value。
node.nodeType:读取节点类型(1=元素,3=文本)。
node.nodeName:读取节点名称(元素名字或#textNode)。
node.nodeValue:读取或设置节点的值。(文本情况下为文本的内容)。
node.previousSibling:获取上一个兄弟节点,并保存为对象。
node.nextSibling:获取上一个兄弟节点,并保存为对象。
node.childNodes:获取对象的所有子节点,并把它保存到一个对象类表中。
node.firstNode:第一个子节点。
node.lastNode:最后一个子节点。
node.parentNode:获取包含node的节点。
document.createElement(element):创建一个名字为element的新节点,需要提供一个字
符串形式的的元素名。
document.createTextNode(string):创建一个节点值为string的文本节点。
newNode=node.cloneNode(bool):创建newNode作为node的副本。如果bool值为true,这个
clone将包括原节点的所有子节点和属性的克隆。node.appendChild(newNode):将node作为子节点,添加在node的所有子节点之后。
node.insertBefore(newNode,oldNode);在node节点的子节点oldNode之前插入newNode。
node.removeChild(oldNode):移除node的子节点oldNode。
node.replaceChild(newNode,oldNode):替换。
element.innerHTML:读写给定的element的HTML的内容,它是一个字符串,包括所有子节点
及它们的属性和文本内容。