ParentNode

翻譯不完整。請協助 翻譯此英文文件

ParentNode 介面定義了可以擁有子節點之 Node 物件的方法。

ParentNode 是一個原始的介面,且不能以此建立物件實體。ElementDocument 及 DocumentFragment 物件皆實作了 ParentNode

屬性

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

方法

ParentNode.append()
Inserts a set of Node objects or DOMString objects after the last child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.
ParentNode.prepend()
Inserts a set of Node objects or DOMString objects before the first child of the ParentNode. DOMString objects are inserted as equivalent Text nodes.
ParentNode.querySelector()
Returns the first Element with the current element as root that matches the specified group of selectors.
ParentNode.querySelectorAll()
Returns a NodeList representing a list of elements with the current element as root that matches the specified group of selectors.

規範

Specification Status Comment
DOM
The definition of 'ParentNode' in that specification.
Living Standard Added the append() and prepend() methods.
DOM4
The definition of 'ParentNode' in that specification.
Recommendation 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 and the querySelector() and querySelectorAll() methods.
Element Traversal Specification
The definition of 'ElementTraversal' in that specification.
Recommendation Added the initial definition of its properties to the ElementTraversal pure interface and used 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 (25) No support 16.0 No support
append() and prepend() 54.0 49 (49) (Yes) 39 No support
Feature Android Android Webview Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile Chrome for Mobile
Basic support (on Element) (Yes) (Yes) 1.0 (1.9.1) (Yes) (Yes) (Yes) (Yes)
Support on Document and DocumentFragment (Yes) (Yes) 25.0 (25) No support 16.0 No support (Yes)
append() and prepend() No support 54.0 49.0 (49) No support 39 No support 54.0

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

參見

文件標籤與貢獻者

 此頁面的貢獻者: jackblackevo
 最近更新: jackblackevo,