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

createComment() は新たにコメントノードを作成し、返します。

+ +

構文

+ +
CommentNode = document.createComment(data);
+
+ +

引数

+ +
+
data
+
文字列で、コメントに追加されるデータを含みます。
+
+ +

+ +
var docu = new DOMParser().parseFromString('<xml></xml>',  'application/xml');
+var comment = docu.createComment('This is a not-so-secret comment in your document');
+
+docu.getElementsByTagName('xml')[0].appendChild(comment);
+
+alert(new XMLSerializer().serializeToString(docu));
+// 表示結果: <xml><!--This is a not-so-secret comment in your document--></xml>
+ +

仕様書

+ + + + + + + + + + + + + + + + +
仕様書状態備考
{{SpecName('DOM WHATWG', '#dom-document-createcomment', 'document.createComment')}}{{Spec2('DOM WHATWG')}}
+ +

ブラウザーの互換性

+ + + +

{{Compat("api.Document.createComment")}}

-- cgit v1.2.3-54-g00ecf