HTML DOMドキュメントcreateComment()
例
コメントノードを作成し、それをドキュメントに追加します。
const comment = document.createComment("My comments");
document.body.appendChild(comment);
定義と使用法
このcreateComment()
メソッドはコメントを作成し、コメントノードを返します。
構文
document.createComment(text)
パラメーター
Parameter | Description |
text | Optional. The comment text. |
戻り値
タイプ | 説明 |
ノード | 作成されたコメントノード。 |
ブラウザのサポート
document.createComment()
DOMレベル1(1998)の機能です。
すべてのブラウザで完全にサポートされています。
Chrome | IE | Edge | Firefox | Safari | Opera |
Yes | 9-11 | Yes | Yes | Yes | Yes |