Create a comment node, and add it to the document:
const comment = document.createComment("My comments");
document.body.appendChild(comment);
Try it Yourself »
The createComment()
method creates a comment and returns the comment node.
document.createComment(
text)
Parameter | Description |
text | Optional. The comment text. |
Type | Description |
Node | The created comment node. |
document.createComment()
is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!