From 2478646b4648d9c3b98482f186e542fc8ca0cc19 Mon Sep 17 00:00:00 2001 From: Irvin Date: Tue, 17 Aug 2021 02:46:21 +0800 Subject: 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 --- files/zh-cn/web/api/element/after/index.html | 91 ++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 files/zh-cn/web/api/element/after/index.html (limited to 'files/zh-cn/web/api/element/after') 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 +--- +
{{APIRef("DOM")}}
+ +

Element.after() 方法会在其父节点的子节点列表中插入一些 {{domxref("Node")}} 或 {{domxref("DOMString")}} 对象。插入位置为该节点之后。{{domxref("DOMString")}} 对象会被以 {{domxref("Text")}} 的形式插入。

+ +

语法

+ +
+after(... nodes)
+
+ +

参数

+ +
+
nodes
+
一组准备插入的 {{domxref("Node")}} 或 {{domxref("DOMString")}} 。
+
+ +

错误

+ + + +

示例

+ +

插入元素

+ +
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>"
+
+ +

插入文本

+ +
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>"
+ +

同时插入元素和文本

+ +
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>"
+ +

规范

+ +{{Specifications}} + +

浏览器兼容性

+ +

{{Compat}}

+ +

相关链接

+ + -- cgit v1.2.3-54-g00ecf