-
attrbute
-
nodeName
- 定义:nodeName属性返回节点的名称
- 使用
console.log(div1.nodeName)
-
nodeValue
- 定义:nodeValue属性返回一个字符串,表示当前节点本身的文本值,该属性可读写只有文本节点(text)、注释节点(comment)和属性节点(attr)有文本值.
- 使用
console.log(div1.childNodes[1].nodeValue)
-
textContent
- 定义:textContent属性返回当前节点和它的所有后代节点的文本内容
- 使用
console.log(div1.textContent)
-
nextSibling
- 定义:nextSibling属性返回紧跟在当前节点后面的第一个同级节点。如果当前节点后面没有同级节点,则返回null
- 使用
console.log(div1.firstChild.nextSibling)
-
previousSibling
- 定义:previousSibling属性返回当前节点前面的、距离最近的一个同级节点。如果当前节点前面没有同级节点,则返回null
- 使用
console.log(div1.lastChild.previousSibling)
-
parentNode
- 定义:parentNode属性返回当前节点的父节点。对于一个节点来说,它的父节点只可能是三种类型:元素节点(element)、文档节点(document)和文档片段节点(documentfragment)
- 使用
console.log(div1.parentNode)
-
parentElement
- 定义:parentElement属性返回当前节点的父元素节点。如果当前节点没有父节点,或者父节点类型不是元素节点,则返回null
- 使用
console.log(div1.parentElement)
-
firstChild和lastChild
- 定义:firstChild属性返回当前节点的第一个子节点,如果当前节点没有子节点,则返回null,last则返回最后一个子节点。
- 使用
console.log("div1.firstChild:",div1.firstChild) console.log("div1.lastChild:",div1.lastChild)
-
childNodes
- 定义:childNodes属性返回一个类似数组的对象(NodeList集合),成员包括当前节点的所有子节点
- 使用
console.log("div1.childNodes:",div1.childNodes)
-
03-29
1750
