aboutsummaryrefslogtreecommitdiff
path: root/files/zh-tw/orphaned
diff options
context:
space:
mode:
authorMDN <actions@users.noreply.github.com>2021-04-16 00:10:51 +0000
committerMDN <actions@users.noreply.github.com>2021-04-16 00:10:51 +0000
commit9daad59fa2578dcc9603833b0a9a22b93d362b5e (patch)
treecf66aa37e5a7f19aff75a5e8d2b2773f0b295048 /files/zh-tw/orphaned
parent91bea6bd04ae368a889436799187eeebb11d33a1 (diff)
downloadtranslated-content-9daad59fa2578dcc9603833b0a9a22b93d362b5e.tar.gz
translated-content-9daad59fa2578dcc9603833b0a9a22b93d362b5e.tar.bz2
translated-content-9daad59fa2578dcc9603833b0a9a22b93d362b5e.zip
[CRON] sync translated content
Diffstat (limited to 'files/zh-tw/orphaned')
-rw-r--r--files/zh-tw/orphaned/web/api/parentnode/firstelementchild/index.html96
1 files changed, 96 insertions, 0 deletions
diff --git a/files/zh-tw/orphaned/web/api/parentnode/firstelementchild/index.html b/files/zh-tw/orphaned/web/api/parentnode/firstelementchild/index.html
new file mode 100644
index 0000000000..ca33d60793
--- /dev/null
+++ b/files/zh-tw/orphaned/web/api/parentnode/firstelementchild/index.html
@@ -0,0 +1,96 @@
+---
+title: ParentNode.firstElementChild
+slug: orphaned/Web/API/ParentNode/firstElementChild
+translation_of: Web/API/ParentNode/firstElementChild
+original_slug: Web/API/ParentNode/firstElementChild
+---
+<p>{{ APIRef("DOM") }}</p>
+
+<p><strong><code>ParentNode.firstElementChild</code></strong> 介面會會返回 <code>ParentNode</code>的第一個子元素(唯讀) ,如果該節點沒有子節點則返回<code>null</code>。</p>
+
+<div class="note">
+<p>This property was initially defined in the {{domxref("ElementTraversal")}} pure interface. As this interface contained two distinct set of properties, one aimed at {{domxref("Node")}} that have children, one at those that are children, they have been moved into two separate pure interfaces, {{domxref("ParentNode")}} and {{domxref("ChildNode")}}. In this case, <code>firstElementChild</code> moved to {{domxref("ParentNode")}}. This is a fairly technical change that shouldn't affect compatibility.</p>
+</div>
+
+<h2 id="Syntax_and_values" name="Syntax_and_values">語法</h2>
+
+<pre class="syntaxbox">var <em>element</em> = node.firstElementChild;
+</pre>
+
+<h2 id="Example" name="Example">範例</h2>
+
+<pre class="brush: html">&lt;ul id="foo"&gt;
+ &lt;li&gt;First (1)&lt;/li&gt;
+ &lt;li&gt;Second (2)&lt;/li&gt;
+ &lt;li&gt;Third (3)&lt;/li&gt;
+&lt;/ul&gt;
+
+&lt;script&gt;
+var foo = document.getElementById('foo');
+// yields: First (1)
+console.log(foo.firstElementChild.textContent);
+&lt;/script&gt;
+</pre>
+
+<h2 id="適用於IE8_IE9_和_Safari的Polyfill">適用於IE8, IE9 和 Safari的Polyfill</h2>
+
+<pre class="brush: js">// Overwrites native 'firstElementChild' prototype.
+// Adds Document &amp; DocumentFragment support for IE9 &amp; Safari.
+;(function(constructor) {
+ if (constructor &amp;&amp;
+ constructor.prototype &amp;&amp;
+ constructor.prototype.firstElementChild == null) {
+ Object.defineProperty(constructor.prototype, 'firstElementChild', {
+ get: function() {
+ var node, nodes = this.childNodes, i = 0;
+ while (node = nodes[i++]) {
+ if (node.nodeType === 1) {
+ return node;
+ }
+ }
+ return null;
+ }
+ });
+ }
+})(window.Node || window.Element);
+</pre>
+
+<h2 id="規範">規範</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', '#dom-parentnode-firstelementchild', 'ParentNode.firstElementChild')}}</td>
+ <td>{{Spec2('DOM WHATWG')}}</td>
+ <td>Split the <code>ElementTraversal</code> interface in {{domxref("ChildNode")}} and <code>ParentNode</code>. This method is now defined on the latter.<br>
+ The {{domxref("Document")}} and {{domxref("DocumentFragment")}} implemented the new interfaces.</td>
+ </tr>
+ <tr>
+ <td>{{SpecName('Element Traversal', '#attribute-firstElementChild', 'ElementTraversal.firstElementChild')}}</td>
+ <td>{{Spec2('Element Traversal')}}</td>
+ <td>Added its initial definition to the <code>ElementTraversal</code> pure interface and use it on {{domxref("Element")}}.</td>
+ </tr>
+ </tbody>
+</table>
+
+<h2 id="瀏覽器相容性">瀏覽器相容性</h2>
+
+
+
+<p>{{Compat("api.ParentNode.firstElementChild")}}</p>
+
+<h2 id="參見">參見</h2>
+
+<ul>
+ <li>{{domxref("NonDocumentTypeChildNode.nextElementSibling")}}</li>
+ <li>{{domxref("ParentNode.lastElementChild")}}</li>
+ <li>The {{domxref("ParentNode")}} and {{domxref("ChildNode")}} pure interfaces.</li>
+ <li>
+ <div class="syntaxbox">Object types implementing this pure interface: {{domxref("Document")}}, {{domxref("Element")}}, and {{domxref("DocumentFragment")}}.</div>
+ </li>
+</ul>