aboutsummaryrefslogtreecommitdiff
path: root/files/zh-cn/web/api/node/parentelement
diff options
context:
space:
mode:
authorPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
committerPeter Bengtsson <mail@peterbe.com>2020-12-08 14:40:17 -0500
commit33058f2b292b3a581333bdfb21b8f671898c5060 (patch)
tree51c3e392513ec574331b2d3f85c394445ea803c6 /files/zh-cn/web/api/node/parentelement
parent8b66d724f7caf0157093fb09cfec8fbd0c6ad50a (diff)
downloadtranslated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.gz
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.tar.bz2
translated-content-33058f2b292b3a581333bdfb21b8f671898c5060.zip
initial commit
Diffstat (limited to 'files/zh-cn/web/api/node/parentelement')
-rw-r--r--files/zh-cn/web/api/node/parentelement/index.html42
1 files changed, 42 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/node/parentelement/index.html b/files/zh-cn/web/api/node/parentelement/index.html
new file mode 100644
index 0000000000..6472201fe4
--- /dev/null
+++ b/files/zh-cn/web/api/node/parentelement/index.html
@@ -0,0 +1,42 @@
+---
+title: Node.parentElement
+slug: Web/API/Node/parentElement
+translation_of: Web/API/Node/parentElement
+---
+<p>{{ ApiRef() }}</p>
+
+<p>返回当前节点的父元素节点,如果该元素没有父节点,或者父节点不是一个 DOM {{domxref("Element", "元素")}},则返回 <code>null</code>。</p>
+
+<h2 id="语法">语法</h2>
+
+<pre class="syntaxbox"><em>parentElement</em> = <em>node</em>.parentElement</pre>
+
+<p><code>parentElement</code> 是当前节点的父元素。它永远是一个 DOM {{domxref("Element", "元素")}} 对象,或者 <code>null</code>。</p>
+
+<h2 id="例子">例子</h2>
+
+<pre class="brush:js">if (node.parentElement) {
+ node.parentElement.style.color = "red";
+}</pre>
+
+<h2 id="浏览器兼容性">浏览器兼容性</h2>
+
+<p>在一些浏览器上,<code>parentElement</code> 属性只对自身为 {{domxref("Element")}} 的节点定义,也就是说,对文本节点不定义。</p>
+
+<div>
+
+
+<p>{{Compat("api.Node.parentElement")}}</p>
+</div>
+
+<h2 id="规范">规范</h2>
+
+<ul>
+ <li>{{spec("http://dvcs.w3.org/hg/domcore/raw-file/tip/Overview.html#parent-element", "DOM Level 4: Node.parentElement", "WD")}}</li>
+</ul>
+
+<h2 id="参见">参见</h2>
+
+<ul>
+ <li>{{domxref("Node.parentNode")}}</li>
+</ul>