diff options
author | Irvin <irvinfly@gmail.com> | 2021-08-17 02:46:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-08-17 02:46:21 +0800 |
commit | 2478646b4648d9c3b98482f186e542fc8ca0cc19 (patch) | |
tree | ed2cf4a397e5e6bd4bce72edae928494bb6dbac6 /files/zh-cn/web/api/element/after | |
parent | 13655caf6054c012946aa786a0675c8556c49805 (diff) | |
download | translated-content-2478646b4648d9c3b98482f186e542fc8ca0cc19.tar.gz translated-content-2478646b4648d9c3b98482f186e542fc8ca0cc19.tar.bz2 translated-content-2478646b4648d9c3b98482f186e542fc8ca0cc19.zip |
bring some orphaned docs and relocate according to it's counterpart eng doc (partial revert #1616) (#1618)
* Revert "Remove previously orphaned file (#1616)"
This reverts commit 49c5601989809c347a5a595e3c5edc08731e5305.
* fix broken slugs
* rm orphaned docs that eng origin is not available
* Web/API/Element/after: sync origin english content
Diffstat (limited to 'files/zh-cn/web/api/element/after')
-rw-r--r-- | files/zh-cn/web/api/element/after/index.html | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/files/zh-cn/web/api/element/after/index.html b/files/zh-cn/web/api/element/after/index.html new file mode 100644 index 0000000000..ea111ec412 --- /dev/null +++ b/files/zh-cn/web/api/element/after/index.html @@ -0,0 +1,91 @@ +--- +title: Element.after() +slug: Web/API/Element/after +translation_of: Web/API/Element/after +original_slug: Web/API/ChildNode/after +tags: + - API + - DOM + - Method + - Node + - Reference +browser-compat: api.Element.after +--- +<div>{{APIRef("DOM")}}</div> + +<p><strong><code>Element.after()</code> </strong>方法会在其父节点的子节点列表中插入一些 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。插入位置为该节点之后。{{domxref("DOMString")}} 对象会被以 {{domxref("Text")}} 的形式插入。</p> + +<h2 id="Syntax">语法</h2> + +<pre class="brush: js"> +after(... nodes) +</pre> + +<h3 id="Parameters">参数</h3> + +<dl> + <dt><code>nodes</code></dt> + <dd>一组准备插入的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 。</dd> +</dl> + +<h3 id="Exceptions">错误</h3> + +<ul> + <li>{{domxref("HierarchyRequestError")}}: 在某些不正确的层级结构进行了插入操作。</li> +</ul> + +<h2 id="Examples">示例</h2> + +<h3 id="Inserting_an_element">插入元素</h3> + +<pre class="brush: js">let container = document.createElement("div"); +let p = document.createElement("p"); +container.appendChild(p); +let span = document.createElement("span"); + +p.after(span); + +console.log(container.outerHTML); +// "<div><p></p><span></span></div>" +</pre> + +<h3 id="Inserting_text">插入文本</h3> + +<pre class="brush: js">let container = document.createElement("div"); +let p = document.createElement("p"); +container.appendChild(p); + +p.after("Text"); + +console.log(container.outerHTML); +// "<div><p></p>Text</div>"</pre> + +<h3 id="Inserting_an_element_and_text">同时插入元素和文本</h3> + +<pre class="brush: js">let container = document.createElement("div"); +let p = document.createElement("p"); +container.appendChild(p); +let span = document.createElement("span"); + +p.after(span, "Text"); + +console.log(container.outerHTML); +// "<div><p></p><span></span>Text</div>"</pre> + +<h2 id="Specifications">规范</h2> + +{{Specifications}} + +<h2 id="Browser_compatibility">浏览器兼容性</h2> + +<p>{{Compat}}</p> + +<h2 id="See_also">相关链接</h2> + +<ul> + <li>{{domxref("Element.before()")}}</li> + <li>{{domxref("Element.append()")}}</li> + <li>{{domxref("Node.appendChild()")}}</li> + <li>{{domxref("Element.insertAdjacentElement()")}}</li> + <li>{{domxref("NodeList")}}</li> +</ul> |