Node

  • Revision slug: DOM/Node
  • Revision title: Node
  • Revision id: 345409
  • Created:
  • Creator: evilpie
  • Is current revision? No
  • Comment added whatwg node interface

Revision Content

{{domref}}

A Node is an interface from which a number of DOM types inherit, and allows these various types to be treated (or tested) similarly.
The following all inherit this interface and its methods and properties (though they may return null in particular cases where not relevant; or throw an exception when adding children to a node type for which no children can exist): {{domxref("Document")}}, {{domxref("Element")}}, {{domxref("Attr")}}, {{domxref("CharacterData")}} (which {{domxref("Text")}}, {{domxref("Comment")}}, and {{domxref("CDATASection")}} inherit), {{domxref("ProcessingInstruction")}}, {{domxref("DocumentFragment")}}, {{domxref("DocumentType")}}, {{domxref("Notation")}}, {{domxref("Entity")}}, {{domxref("EntityReference")}}

Properties

  • {{domxref("Node.attributes")}}
  • {{domxref("Node.baseURI")}}
  • {{domxref("Node.childNodes")}}
  • {{domxref("Node.firstChild")}}
  • {{domxref("Node.lastChild")}}
  • {{domxref("Node.localName")}}
  • {{domxref("Node.namespaceURI")}}
  • {{domxref("Node.nextSibling")}}
  • {{domxref("Node.nodeName")}}
  • {{domxref("Node.nodePrincipal")}}
  • {{domxref("Node.nodeType")}}
  • {{domxref("Node.nodeValue")}}
  • {{domxref("Node.ownerDocument")}}
  • {{domxref("Node.parentNode")}}
  • {{domxref("Node.parentElement")}}
  • {{domxref("Node.prefix")}}
  • {{domxref("Node.previousSibling")}}
  • {{domxref("Node.textContent")}}

Methods

  • {{domxref("Node.appendChild")}}
  • {{domxref("Node.cloneNode")}}
  • {{domxref("Node.compareDocumentPosition")}}
  • {{domxref("Node.contains")}}
  • {{domxref("Node.getFeature")}} {{obsolete_inline("7.0")}}
  • {{domxref("Node.getUserData")}}
  • {{domxref("Node.hasAttributes")}}
  • {{domxref("Node.hasChildNodes")}}
  • {{domxref("Node.insertBefore")}}
  • {{domxref("Node.isDefaultNamespace")}}
  • {{domxref("Node.isEqualNode")}}
  • {{domxref("Node.isSameNode")}} {{deprecated_inline("9.0")}} {{obsolete_inline("10.0")}}
  • {{domxref("Node.isSupported")}}
  • {{domxref("Node.lookupPrefix")}}
  • {{domxref("Node.lookupNamespaceURI")}}
  • {{domxref("Node.normalize")}}
  • {{domxref("Node.removeChild")}}
  • {{domxref("Node.replaceChild")}}
  • {{domxref("Node.setUserData")}}

Constants

See also {{domxref("Node.nodeType")}}

Name Value
ELEMENT_NODE 1
ATTRIBUTE_NODE 2
TEXT_NODE 3
DATA_SECTION_NODE 4
ENTITY_REFERENCE_NODE 5
ENTITY_NODE 6
PROCESSING_INSTRUCTION_NODE 7
COMMENT_NODE 8
DOCUMENT_NODE 9
DOCUMENT_TYPE_NODE 10
DOCUMENT_FRAGMENT_NODE 11
NOTATION_NODE 12
DOCUMENT_POSITION_DISCONNECTED 0x01
DOCUMENT_POSITION_PRECEDING 0x02
DOCUMENT_POSITION_FOLLOWING 0x04
DOCUMENT_POSITION_CONTAINS 0x08
DOCUMENT_POSITION_CONTAINED_BY 0x10
DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC 0x20

Specifications

Revision Source

<div>
  {{domref}}</div>
<p>A <code>Node</code> is an interface from which a number of DOM types inherit, and allows these various types to be treated (or tested) similarly.<br />
  The following all inherit this interface and its methods and properties (though they may return null in particular cases where not relevant; or throw an exception when adding children to a node type for which no children can exist): {{domxref("Document")}}, {{domxref("Element")}}, {{domxref("Attr")}}, {{domxref("CharacterData")}} (which {{domxref("Text")}}, {{domxref("Comment")}}, and {{domxref("CDATASection")}} inherit), {{domxref("ProcessingInstruction")}}, {{domxref("DocumentFragment")}}, {{domxref("DocumentType")}}, {{domxref("Notation")}}, {{domxref("Entity")}}, {{domxref("EntityReference")}}</p>
<h2 id="Properties">Properties</h2>
<ul>
  <li>{{domxref("Node.attributes")}}</li>
  <li>{{domxref("Node.baseURI")}}</li>
  <li>{{domxref("Node.childNodes")}}</li>
  <li>{{domxref("Node.firstChild")}}</li>
  <li>{{domxref("Node.lastChild")}}</li>
  <li>{{domxref("Node.localName")}}</li>
  <li>{{domxref("Node.namespaceURI")}}</li>
  <li>{{domxref("Node.nextSibling")}}</li>
  <li>{{domxref("Node.nodeName")}}</li>
  <li>{{domxref("Node.nodePrincipal")}}</li>
  <li>{{domxref("Node.nodeType")}}</li>
  <li>{{domxref("Node.nodeValue")}}</li>
  <li>{{domxref("Node.ownerDocument")}}</li>
  <li>{{domxref("Node.parentNode")}}</li>
  <li>{{domxref("Node.parentElement")}}</li>
  <li>{{domxref("Node.prefix")}}</li>
  <li>{{domxref("Node.previousSibling")}}</li>
  <li>{{domxref("Node.textContent")}}</li>
</ul>
<h2 id="Methods">Methods</h2>
<ul>
  <li>{{domxref("Node.appendChild")}}</li>
  <li>{{domxref("Node.cloneNode")}}</li>
  <li>{{domxref("Node.compareDocumentPosition")}}</li>
  <li>{{domxref("Node.contains")}}</li>
  <li>{{domxref("Node.getFeature")}} {{obsolete_inline("7.0")}}</li>
  <li>{{domxref("Node.getUserData")}}</li>
  <li>{{domxref("Node.hasAttributes")}}</li>
  <li>{{domxref("Node.hasChildNodes")}}</li>
  <li>{{domxref("Node.insertBefore")}}</li>
  <li>{{domxref("Node.isDefaultNamespace")}}</li>
  <li>{{domxref("Node.isEqualNode")}}</li>
  <li>{{domxref("Node.isSameNode")}} {{deprecated_inline("9.0")}} {{obsolete_inline("10.0")}}</li>
  <li>{{domxref("Node.isSupported")}}</li>
  <li>{{domxref("Node.lookupPrefix")}}</li>
  <li>{{domxref("Node.lookupNamespaceURI")}}</li>
  <li>{{domxref("Node.normalize")}}</li>
  <li>{{domxref("Node.removeChild")}}</li>
  <li>{{domxref("Node.replaceChild")}}</li>
  <li>{{domxref("Node.setUserData")}}</li>
</ul>
<h2 id="Constants">Constants</h2>
<p>See also {{domxref("Node.nodeType")}}</p>
<table class="standard-table" summary="A list of constants on Node">
  <tbody>
    <tr>
      <th>Name</th>
      <th>Value</th>
    </tr>
    <tr>
      <td><code>ELEMENT_NODE</code></td>
      <td>1</td>
    </tr>
    <tr>
      <td><code>ATTRIBUTE_NODE</code></td>
      <td>2</td>
    </tr>
    <tr>
      <td><code>TEXT_NODE</code></td>
      <td>3</td>
    </tr>
    <tr>
      <td><code>DATA_SECTION_NODE</code></td>
      <td>4</td>
    </tr>
    <tr>
      <td><code>ENTITY_REFERENCE_NODE</code></td>
      <td>5</td>
    </tr>
    <tr>
      <td><code>ENTITY_NODE</code></td>
      <td>6</td>
    </tr>
    <tr>
      <td><code>PROCESSING_INSTRUCTION_NODE</code></td>
      <td>7</td>
    </tr>
    <tr>
      <td><code>COMMENT_NODE</code></td>
      <td>8</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_NODE</code></td>
      <td>9</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_TYPE_NODE</code></td>
      <td>10</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_FRAGMENT_NODE</code></td>
      <td>11</td>
    </tr>
    <tr>
      <td><code>NOTATION_NODE</code></td>
      <td>12</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_POSITION_DISCONNECTED</code></td>
      <td>0x01</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_POSITION_PRECEDING</code></td>
      <td>0x02</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_POSITION_FOLLOWING</code></td>
      <td>0x04</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_POSITION_CONTAINS</code></td>
      <td>0x08</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_POSITION_CONTAINED_BY</code></td>
      <td>0x10</td>
    </tr>
    <tr>
      <td><code>DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC</code></td>
      <td>0x20</td>
    </tr>
  </tbody>
</table>
<h2 id="Specifications">Specifications</h2>
<ul>
  <li><a class="external" href="http://www.w3.org/TR/REC-DOM-Level-1/level-one-core.html#ID-1950641247">DOM Level 1 Core: Node interface</a></li>
  <li><a class="external" href="http://www.w3.org/TR/DOM-Level-2-Core/core.html#ID-1950641247">DOM Level 2 Core: Node interface</a></li>
  <li><a class="external" href="http://www.w3.org/TR/DOM-Level-3-Core/core.html#ID-1950641247">DOM Level 3 Core: Node interface</a></li>
  <li><a href="http://dom.spec.whatwg.org/#interface-node" title="http://dom.spec.whatwg.org/#interface-node">DOM Standard: Node Interface</a></li>
</ul>
Revert to this revision