--- title: ParentNode slug: Web/API/ParentNode translation_of: Web/API/ParentNode ---
ParentNode
介面定義了可以擁有子節點之 {{domxref("Node")}} 物件的方法。
ParentNode
是一個原始的介面,且不能以此建立物件實體。{{domxref("Element")}}、{{domxref("Document")}} 及 {{domxref("DocumentFragment")}} 物件皆實作了 ParentNode
。
ParentNode
的所有子元素節點,需要特別注意的是:該屬性為唯讀
。ParentNode
的第一個子元素 ,如果該節點沒有子節點則返回null
。ParentNode
的最後一個子元素 ,如果該節點沒有子節點則返回null
。無符號長整數
,該值表示了該節點的子節點數量。ParentNode
. {{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.ParentNode
. {{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.Specification | Status | Comment |
---|---|---|
{{SpecName('DOM WHATWG', '#parentnode', 'ParentNode')}} | {{Spec2('DOM WHATWG')}} | Added the append() and prepend() methods. |
{{SpecName('DOM4', '#parentnode', 'ParentNode')}} | {{Spec2('DOM4')}} | Splitted the ElementTraversal interface in {{domxref("ChildNode")}} and ParentNode . The firstElementChild , lastElementChild , and childElementCount properties are now defined on the latter.The {{domxref("Document")}} and {{domxref("DocumentFragment")}} implemented the new interfaces. Added the children property and the querySelector() and querySelectorAll() methods. |
{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}} | {{Spec2('Element Traversal')}} | Added the initial definition of its properties to the ElementTraversal pure interface and used it on {{domxref("Element")}}. |
{{CompatibilityTable}}
Feature | Chrome | Firefox (Gecko) | Internet Explorer | Opera | Safari |
---|---|---|---|---|---|
Basic support (on {{domxref("Element")}}) | {{CompatChrome(1.0)}} | {{CompatGeckoDesktop("1.9.1")}} | 9.0 [1] | 10.0 | 4.0 |
Support on {{domxref("Document")}} and {{domxref("DocumentFragment")}} {{experimental_inline}} | {{CompatChrome(29.0)}} | {{CompatGeckoDesktop(25)}} | {{CompatNo}} | 16.0 | {{CompatNo}} |
append() and prepend() {{experimental_inline}} |
{{CompatChrome(54.0)}} | {{CompatGeckoDesktop(49)}} | {{CompatVersionUnknown}} | {{CompatOpera(39)}} | {{CompatNo}} |
Feature | Android | Android Webview | Firefox Mobile (Gecko) | IE Mobile | Opera Mobile | Safari Mobile | Chrome for Mobile |
---|---|---|---|---|---|---|---|
Basic support (on {{domxref("Element")}}) | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile("1.9.1")}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} |
Support on {{domxref("Document")}} and {{domxref("DocumentFragment")}} {{experimental_inline}} | {{CompatVersionUnknown}} | {{CompatVersionUnknown}} | {{CompatGeckoMobile(25)}} | {{CompatNo}} | 16.0 | {{CompatNo}} | {{CompatVersionUnknown}} |
append() and prepend() {{experimental_inline}} |
{{CompatNo}} | {{CompatChrome(54.0)}} | {{CompatGeckoMobile(49)}} | {{CompatNo}} | {{CompatOperaMobile(39)}} | {{CompatNo}} | {{CompatChrome(54.0)}} |
[1] Internet Explorer 6, 7 and 8 supported it, but erroneously returns {{domxref("Comment")}} nodes as part of the results.