ParentNode

ParentNode mixin包含可以拥有子项的所有类型的 Node对象共有的方法和属性。

ParentNode 是一个原始接口,不能够创建这种类型的对象;它在 ElementDocumentDocumentFragment 对象上被实现。

 

属性

ParentNode.children 只读
Returns a live HTMLCollection containing all objects of type Element that are children of this ParentNode.
ParentNode.firstElementChild 只读
Returns the Element that is the first child of this ParentNode, or null if there is none.
ParentNode.lastElementChild 只读
Returns the Element that is the last child of this ParentNode, or null if there is none.
ParentNode.childElementCount 只读
Returns an unsigned long giving the amount of children that the object has.

方法

There is no inherited or specific and implemented methods.

规范

Specification Status Comment
DOM
ParentNode.firstElementChild
Living Standard Splitted the ElementTraversal interface in ChildNode and ParentNode. The firstElementChild, lastElementChild, and childElementCount properties are now defined on the latter.
The Document and DocumentFragment implemented the new interfaces.
Added the children property.
Added the append() and prepend() methods.
Element Traversal Specification
ElementTraversal
'
Recommendation Added the initial definition of its properties to the ElementTraversal pure interface and use it on Element.

浏览器兼容性

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (on Element) 1.0 3.5 (1.9.1) 9.0 [1] 10.0 4.0
Support on Document and DocumentFragment 29.0 25.0 (25.0) 未实现 16.0 未实现
append() and prepend() 未实现 未实现 未实现 未实现 未实现
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (on Element) (Yes) 1.0 (1.9.1) (Yes) (Yes) (Yes)
Support on Document and DocumentFragment (Yes) 25.0 (25.0) 未实现 16.0 未实现
append() and prepend() 未实现 未实现 未实现 未实现 未实现

[1] Internet Explorer 6, 7 and 8 supported it, but erroneously returns Comment nodes as part of the results.

相关链接

文档标签和贡献者