Javascript Dom树遍历

Node接口定义的节点类型都包含的特性和方法
特性和方法后面的 “冒号:” 紧跟的单词是“返回值类型 ”

Node 

属性

遍历节点(短途旅行):

parentNode : Node
firstChild : Node 
lastChild : Node 
nextSibling : Node 
previousSibling : Node 
childNodes : NodeList 

节点信息: 

nodeName :String 
nodeType :number 
nodeValue :String 

返回一个节点的根元素(文档对象): 

ownerDocument : Document 

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

attributes : NamedNodeMap 

获取对象层次中的父对象: 

parentElement [IE] :Node 

方法 

修改文档树: 

appendChild(Node newChild) : Node 
insertBefore(Node newChild, Node refChild) : Node 
removeChild(Node oldChild): Node 
replaceChild(Node newChild, Node refChild) : Node 

克隆一个节点: 

cloneNode(boolean deep) : Node 

删除一个子节点: 

removeNode(boolean removeChildren) : Node 

判断childNodes包含是否包含节点: 

hasChildNodes() : boolean


Document 

属性 

自己的: 

documentElement : Element 

继承 Node : 

attributes, childNodes, firstChild, lastChild, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentElement, parentNode, previousSibling 

方法 

自己的: 

创建元素: 
createElement(String tagName) : Element 
createTextNode(String data) : Text 
查找元素: 
getElementById(String elementId) : Element 
getElementsByTagName(String tagname) : NodeList 

继承 Node : 

appendChild, cloneNode, hasChildNodes, insertBefore, removeChild, removeNode, replaceChild




Element 

属性 

自己的: 

tagName: String 

继承 Node : 

attributes, childNodes, firstChild, lastChild, nextSibling, nodeName, nodeType, nodeValue, ownerDocument, parentElement, parentNode, previousSibling 

方法 

自己的: 

属性的读写: 
getAttribute(String name) : String 
setAttribute(String name, String value) : void 
其它: 
getElementsByTagName(String name) Stub : NodeList 
normalize() Stub : void 
removeAttribute(String name) : void 

继承 Node : 

appendChild, cloneNode, hasChildNodes, insertBefore, removeChild, removeNode, replaceChild
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值