DOM

Node

nodeType

  document 9

  elem 1

  attr 2

  text 3  

nodeName

  document #document

  elem 全大写标签名

  attr 属性名

  text #text

nodeValue

  document null

  elem null

  attr 属性值

  text 文本内容

DOM Tree

父子 parentNode childNodes firstChild lastChild

兄弟 previousSibling nextSibling

Element Tree

父子 parentElement children firstElementChild lastElementChild

兄弟 previousElementSibling nextElementSibling

方法

parentNode.removeChild(oldNode)

parentNode.replaceChild(newNode,oldNode)

parentNode.appendChild(newNode)

parentNode.insertBefore(newNode,childNodes[?])

node.cloneNode()

document.createElement()

document.createTextNode()

document.createAttribute()

setAttribute()

getAttribute()

原文地址:https://www.cnblogs.com/churjan/p/6384573.html