document、element、node方法

document方法:
  • getElementById(id)返回指定结点的引用
  • getElementsByTagName(name) 返回文档中所有匹配的元素的集合
  • createElement(name)创建指定类型的新结点
  • createTextNode(text)创建一个纯文本结点
element方法:
  • getAttribute(id)返回指定属性的值
  • setAttribute(id,value)给属性赋值
  • removeAttribute(id)移除指定属性和它的值
  • getElementsByTagName(name)
node方法:
  • appendChild(child)给指定结点添加一个新的子结点
  • removeChild(child)移除指定结点的子结点
  • replaceChild(newChild,oldChild) 替换指定结点的子结点
  • insertBefore(newChild,refChild) 在同一层级的结点前面插入新结点
  • hasChildNodes()如果结点有子结点则返回true
node属性:
  • nodeName以字符串的格式存放结点的名称
  • nodeType以整型数据格式存放结点的类型
  • nodeValue以可用的格式存放结点的值
  • parentNode指向结点的父结点的引用
  • childNodes指向子结点的引用的集合
  • firstChild指向子结点结合中的第一个子结点的引用
  • lastChild指向子结点结合中的最后一个子结点的引用
原文地址:https://www.cnblogs.com/netwenchao/p/1662621.html