diff options
Diffstat (limited to 'files/de/web/api/node/haschildnodes/index.html')
-rw-r--r-- | files/de/web/api/node/haschildnodes/index.html | 120 |
1 files changed, 120 insertions, 0 deletions
diff --git a/files/de/web/api/node/haschildnodes/index.html b/files/de/web/api/node/haschildnodes/index.html new file mode 100644 index 0000000000..1ecfb52b48 --- /dev/null +++ b/files/de/web/api/node/haschildnodes/index.html @@ -0,0 +1,120 @@ +--- +title: Node.hasChildNodes() +slug: Web/API/Node/hasChildNodes +tags: + - API DOM Methode Node +translation_of: Web/API/Node/hasChildNodes +--- +<div> +<div>{{APIRef("DOM")}}</div> +</div> + +<p>Die <code><strong>Node.hasChildNodes()</strong></code> Methode liefert einen <strong>Boolean</strong> Wert der anzeigt ob die aktuelle {{domxref("Node")}} <a href="/en-US/docs/Web/API/Node.childNodes" title="DOM/Node.childNodes">child nodes</a> hat oder nicht.</p> + +<h2 id="Syntax" name="Syntax">Syntax</h2> + +<pre class="syntaxbox"><code><em>result</em> = <em>node</em>.hasChildNodes();</code></pre> + +<dl> + <dt><code>result</code></dt> + <dd>enthält den return Wert <code>true</code> oder <code>false</code>.</dd> +</dl> + +<h2 id="Example" name="Example">Beispiele</h2> + +<p>Das nächste Beispiel entfernt die erste child node innerhalb dem element mit der id <code>"foo"</code> wenn foo child nodes enthält.</p> + +<pre class="brush:js">var foo = document.getElementById("foo"); +if (foo.hasChildNodes()) { + // do something with 'foo.childNodes' +} +</pre> + +<h2 id="Polyfill">Polyfill</h2> + +<pre class="brush:js">;(function(prototype) { + prototype.hasChildNodes = prototype.hasChildNodes || function() { + return !!this.firstChild; + } +})(Node.prototype); +</pre> + +<h2 id="Zusammenfassung">Zusammenfassung</h2> + +<p>Es gibt unterschiedliche Wege herauszufinden ob die node eine child node enthält.</p> + +<ul> + <li>node.hasChildNodes()</li> + <li>node.firstChild != null (or just node.firstChild)</li> + <li>node.childNodes && node.childNodes.length (or node.childNodes.length > 0)</li> +</ul> + +<h2 id="Specification" name="Specification">Spezifikation</h2> + +<ul> + <li><a href="https://dom.spec.whatwg.org/#dom-node-haschildnodes">WHATWG: hasChildNodes</a></li> + <li><a class="external" href="http://www.w3.org/TR/2000/REC-DOM-Level-2-Core-20001113/core.html#ID-810594187">hasChildNodes</a></li> +</ul> + +<h2 id="Browser_Kompatibilität">Browser Kompatibilität</h2> + +<p>{{CompatibilityTable}}</p> + +<div id="compat-desktop"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Chrome</th> + <th>Edge</th> + <th>Firefox (Gecko)</th> + <th>Internet Explorer</th> + <th>Opera</th> + <th>Safari</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>7.0</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<div id="compat-mobile"> +<table class="compat-table"> + <tbody> + <tr> + <th>Feature</th> + <th>Android</th> + <th>Edge</th> + <th>Firefox Mobile (Gecko)</th> + <th>IE Mobile</th> + <th>Opera Mobile</th> + <th>Safari Mobile</th> + </tr> + <tr> + <td>Basic support</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + <td>{{CompatVersionUnknown}}</td> + </tr> + </tbody> +</table> +</div> + +<p> </p> + +<h2 id="See_also" name="See_also">Siehe auch</h2> + +<ul> + <li>{{domxref("Node.childNodes")}}</li> + <li>{{domxref("Node.hasAttributes")}}</li> +</ul> |