aboutsummaryrefslogtreecommitdiff
path: root/files/ja/web/api/document/createcomment/index.html
blob: 4597c5f1b7cc8ade559e9c57e159a1b123109e0d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
---
title: Document.createComment()
slug: Web/API/Document/createComment
tags:
  - API
  - DOM
  - Method
  - Reference
translation_of: Web/API/Document/createComment
---
<div>{{APIRef("DOM")}}</div>

<p><strong><code>createComment()</code></strong> は新たにコメントノードを作成し、返します。</p>

<h2 id="Syntax" name="Syntax">構文</h2>

<pre class="syntaxbox notranslate"><var>CommentNode</var> = <var>document</var>.createComment(<var>data</var>);
</pre>

<h3 id="Parameters" name="Parameters">引数</h3>

<dl>
 <dt><var>data</var></dt>
 <dd>文字列で、コメントに追加されるデータを含みます。</dd>
</dl>

<h2 id="Example" name="Example"></h2>

<pre class="brush:js notranslate">var docu = new DOMParser().parseFromString('&lt;xml&gt;&lt;/xml&gt;',  '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));
// 表示結果: &lt;xml&gt;&lt;!--This is a not-so-secret comment in your document--&gt;&lt;/xml&gt;</pre>

<h2 id="Specifications" name="Specifications">仕様書</h2>

<table class="standard-table">
 <thead>
  <tr>
   <th scope="col">仕様書</th>
   <th scope="col">状態</th>
   <th scope="col">備考</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <td>{{SpecName('DOM WHATWG', '#dom-document-createcomment', 'document.createComment')}}</td>
   <td>{{Spec2('DOM WHATWG')}}</td>
   <td></td>
  </tr>
 </tbody>
</table>

<h2 id="Browser_compatibility" name="Browser_compatibility">ブラウザーの互換性</h2>

<p>{{Compat("api.Document.createComment")}}</p>