Please note, this is a STATIC archive of website developer.mozilla.org from 03 Nov 2016, cach3.com does not collect or store any user information, there is no "phishing" involved.

Revision 742255 of ChildNode

  • Revision slug: Web/API/ChildNode
  • Revision title: ChildNode
  • Revision id: 742255
  • Created:
  • Creator: fscholz
  • Is current revision? No
  • Comment group

Revision Content

{{APIRef("DOM")}}

The ChildNode interface contains methods that are particular to {{domxref("Node")}} objects that can have a parent.

ChildNode is a raw interface and no object of this type can be created; it is implemented by {{domxref("Element")}}, {{domxref("DocumentType")}}, and {{domxref("CharacterData")}} objects.

Properties

There is neither inherited, nor specific property.

Methods

There is no inherited method.

{{domxref("ChildNode.remove()")}} {{experimental_inline}}
Removes this ChildNode from the children list of its parent.
{{domxref("ChildNode.before()")}} {{experimental_inline}}
Inserts a set of {{domxref("Node")}} or {{domxref("DOMString")}} objects in the children list of this ChildNode's parent, just before this ChildNode. {{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.
{{domxref("ChildNode.after()")}} {{experimental_inline}}
Inserts a set of {{domxref("Node")}} or {{domxref("DOMString")}} objects in the children list of this ChildNode's parent, just after this ChildNode. {{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.
{{domxref("ChildNode.replace()")}} {{experimental_inline}}
Replace this ChildNode in the children list of its parent with a set of {{domxref("Node")}} or {{domxref("DOMString")}} objects. {{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.

Specifications

Specification Status Comment
{{SpecName('DOM WHATWG', '#interface-childnode', 'ChildNode')}} {{Spec2('DOM WHATWG')}} Splitted the ElementTraversal interface in {{domxref("ParentNode")}} and ChildNode. The previousElementSibling and nextElementSibling are now defined on the latter.
The {{domxref("CharacterData")}} and {{domxref("DocumentType")}} implemented the new interfaces.
Added the remove(), before(), after() and replace() methods.
{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}} {{Spec2('Element Traversal')}} Added the initial definition of its properties to the ElementTraversal pure interface and use it on {{domxref("Element")}}.

Browser compatibility

{{ CompatibilityTable() }}

Feature Chrome Firefox (Gecko) Internet Explorer Opera Safari
Basic support (on {{domxref("Element")}}) 1.0 {{CompatGeckoDesktop("23.0")}} 9.0 [1] 10.0 4.0
Support on {{domxref("DocumentType")}} and {{domxref("CharacterData")}} {{experimental_inline}} 23.0 {{CompatGeckoDesktop("23.0")}} {{CompatNo}} 16.0 {{CompatNo}}
remove(){{experimental_inline}} 29.0 {{CompatGeckoDesktop("23.0")}} {{CompatNo}} 16.0 {{CompatNo}}
before(), after(), and replace() {{experimental_inline}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}}
Feature Android Firefox Mobile (Gecko) IE Mobile Opera Mobile Safari Mobile
Basic support (on {{domxref("Element")}}) {{ CompatVersionUnknown() }} {{CompatGeckoMobile("23.0")}} {{ CompatVersionUnknown() }} 10.0 {{ CompatVersionUnknown() }}
Support on {{domxref("DocumentType")}} and {{domxref("CharacterData")}} {{experimental_inline}} {{ CompatVersionUnknown() }} {{CompatGeckoMobile("23.0")}} {{CompatNo}} 16.0 {{CompatNo}}
remove(){{experimental_inline}} {{CompatVersionUnknown}} {{CompatGeckoMobile("23.0")}} {{CompatNo}} 16.0 {{CompatNo}}
before(), after(), and replace() {{experimental_inline}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}} {{CompatNo}}

See also

  • The {{domxref("ParentNode")}} pure interface.
  • Object types implementing this pure interface: {{domxref("CharacterData")}}, {{domxref("Element")}}, and {{domxref("DocumentType")}}.

Revision Source

<p>{{APIRef("DOM")}}</p>

<p>The <code><strong>ChildNode</strong></code> interface contains methods that are particular to {{domxref("Node")}} objects that can have a parent.</p>

<p><code>ChildNode</code> is a raw interface and no object of this type can be created; it is implemented by {{domxref("Element")}}, {{domxref("DocumentType")}}, and {{domxref("CharacterData")}} objects.</p>

<h2 id="Properties">Properties</h2>

<p><em>There is neither inherited, nor specific property.</em></p>

<h2 id="Methods">Methods</h2>

<p><em>There is no inherited method.</em></p>

<dl>
 <dt>{{domxref("ChildNode.remove()")}} {{experimental_inline}}</dt>
 <dd>Removes this <code>ChildNode</code> from the children list of its parent.</dd>
 <dt>{{domxref("ChildNode.before()")}} {{experimental_inline}}</dt>
 <dd>Inserts a set of {{domxref("Node")}} or {{domxref("DOMString")}} objects in the children list of this <code>ChildNode</code>'s parent, just before this <code>ChildNode</code>. {{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.</dd>
 <dt>{{domxref("ChildNode.after()")}} {{experimental_inline}}</dt>
 <dd>Inserts a set of {{domxref("Node")}} or {{domxref("DOMString")}} objects in the children list of this <code>ChildNode</code>'s parent, just after this <code>ChildNode</code>. {{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.</dd>
 <dt>{{domxref("ChildNode.replace()")}} {{experimental_inline}}</dt>
 <dd>Replace this <code>ChildNode</code> in the children list of its parent with a set of {{domxref("Node")}} or {{domxref("DOMString")}} objects. {{domxref("DOMString")}} objects are inserted as equivalent {{domxref("Text")}} nodes.</dd>
</dl>

<h2 id="Specifications">Specifications</h2>

<table class="standard-table">
 <tbody>
  <tr>
   <th scope="col">Specification</th>
   <th scope="col">Status</th>
   <th scope="col">Comment</th>
  </tr>
  <tr>
   <td>{{SpecName('DOM WHATWG', '#interface-childnode', 'ChildNode')}}</td>
   <td>{{Spec2('DOM WHATWG')}}</td>
   <td>Splitted the <code>ElementTraversal</code> interface in {{domxref("ParentNode")}} and <code>ChildNode</code>. The <code>previousElementSibling</code> and <code>nextElementSibling</code> are now defined on the latter.<br />
    The {{domxref("CharacterData")}} and {{domxref("DocumentType")}} implemented the new interfaces.<br />
    Added the <code>remove()</code>, <code>before()</code>, <code>after()</code> and <code>replace()</code> methods.</td>
  </tr>
  <tr>
   <td>{{SpecName('Element Traversal', '#interface-elementTraversal', 'ElementTraversal')}}</td>
   <td>{{Spec2('Element Traversal')}}</td>
   <td>Added the initial definition of its properties to the <code>ElementTraversal</code> pure interface and use it on {{domxref("Element")}}.</td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility">Browser compatibility</h2>

<p>{{ CompatibilityTable() }}</p>

<div id="compat-desktop">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Chrome</th>
   <th>Firefox (Gecko)</th>
   <th>Internet Explorer</th>
   <th>Opera</th>
   <th>Safari</th>
  </tr>
  <tr>
   <td>Basic support (on {{domxref("Element")}})</td>
   <td>1.0</td>
   <td>{{CompatGeckoDesktop("23.0")}}</td>
   <td>9.0 [1]</td>
   <td>10.0</td>
   <td>4.0</td>
  </tr>
  <tr>
   <td>Support on {{domxref("DocumentType")}} and {{domxref("CharacterData")}} {{experimental_inline}}</td>
   <td>23.0</td>
   <td>{{CompatGeckoDesktop("23.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>16.0</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>remove()</code>{{experimental_inline}}</td>
   <td>29.0</td>
   <td>{{CompatGeckoDesktop("23.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>16.0</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>before()</code>, <code>after()</code>, and <code>replace()</code> {{experimental_inline}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<div id="compat-mobile">
<table class="compat-table">
 <tbody>
  <tr>
   <th>Feature</th>
   <th>Android</th>
   <th>Firefox Mobile (Gecko)</th>
   <th>IE Mobile</th>
   <th>Opera Mobile</th>
   <th>Safari Mobile</th>
  </tr>
  <tr>
   <td>Basic support (on {{domxref("Element")}})</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{CompatGeckoMobile("23.0")}}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>10.0</td>
   <td>{{ CompatVersionUnknown() }}</td>
  </tr>
  <tr>
   <td>Support on {{domxref("DocumentType")}} and {{domxref("CharacterData")}} {{experimental_inline}}</td>
   <td>{{ CompatVersionUnknown() }}</td>
   <td>{{CompatGeckoMobile("23.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>16.0</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>remove()</code>{{experimental_inline}}</td>
   <td>{{CompatVersionUnknown}}</td>
   <td>{{CompatGeckoMobile("23.0")}}</td>
   <td>{{CompatNo}}</td>
   <td>16.0</td>
   <td>{{CompatNo}}</td>
  </tr>
  <tr>
   <td><code>before()</code>, <code>after()</code>, and <code>replace()</code> {{experimental_inline}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
   <td>{{CompatNo}}</td>
  </tr>
 </tbody>
</table>
</div>

<h2 id="See_also">See also</h2>

<ul>
 <li>The {{domxref("ParentNode")}} pure interface.</li>
 <li>
  <div class="syntaxbox">Object types implementing this pure interface: {{domxref("CharacterData")}}, {{domxref("Element")}}, and {{domxref("DocumentType")}}.</div>
 </li>
</ul>
Revert to this revision