From 33058f2b292b3a581333bdfb21b8f671898c5060 Mon Sep 17 00:00:00 2001 From: Peter Bengtsson Date: Tue, 8 Dec 2020 14:40:17 -0500 Subject: initial commit --- .../web/api/document/createcomment/index.html | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 files/zh-cn/web/api/document/createcomment/index.html (limited to 'files/zh-cn/web/api/document/createcomment') diff --git a/files/zh-cn/web/api/document/createcomment/index.html b/files/zh-cn/web/api/document/createcomment/index.html new file mode 100644 index 0000000000..1959a87312 --- /dev/null +++ b/files/zh-cn/web/api/document/createcomment/index.html @@ -0,0 +1,33 @@ +--- +title: document.createComment +slug: Web/API/Document/createComment +translation_of: Web/API/Document/createComment +--- +

{{ ApiRef() }}

+

概述

+

createComment() 方法用来创建并返回一个注释节点.

+

语法

+
var commentNode = document.createComment(data)
+
+

参数

+ +

例子

+
var docu = new DOMParser().parseFromString('<xml></xml>',  "application/xml")
+
+var comment = docu.createComment('这是注释内容');
+
+docu.getElementsByTagName('xml')[0].appendChild(comment);
+
+alert(new XMLSerializer().serializeToString(docu));
+// 弹出 <xml><!--这是注释内容--></xml>
+
+

备注

+ +

规范

+

createComment

+

{{ languages( {"en": "en/DOM/document.createComment" } ) }}

-- cgit v1.2.3-54-g00ecf