Node接口的特性与方法

特性/方法

类型/返回类型

   

nodeName

String

节点的名字;根据节点的类型而定义

nodeValue

String

节点的值;根据节点的类型而定义

nodeType

Number

节点的类型常量值之一

ownerDocument

Document

指向这个节点所属的文档

firstChild

Node

指向在childNodes列表中的第一个节点

lastChild

Node

指向在childNodes列表中的最后一个节点

childNodes

NodeList

所有子节点的列表

parentNode

Node

返回一个给定节点的父节点。

previousSibling

Node

指向前一个兄弟节点;如果这个节点就是第一个兄弟节

点,那么该值为null

nextSibling

Node

指向后一个兄弟节点;如果这个节点就是最后一个兄弟节

点,那么该值为null

hasChildNodes()

Boolean

childNodes包含一个或多个节点时,返回真

attributes

NamedNodeMap

包含了代表一个元素的特性的Attr对象;仅用于Element节点

appendChild(node)

Node

node添加到childNodes的末尾

removeChild(node)

Node

childNodes中删除node

replaceChild
(
newnode, oldnode)

Node

childNodes中的oldnode替换成newnode

insertBefore
(
newnode, refnode)

Node

childNodes中的refnode之前插入newnode

猜你喜欢

转载自blog.csdn.net/Ada_yangyang/article/details/81271528