HTML DOM createComment() method
Example
Can create a comment node and insert it into the HTML document:
var c=document.createComment("My personal comments");
document.body.appendChild(c);
Output result:
Try it »
Definition and Usage
The createComment() method creates a comment node.
Browser support





All major browsers support the createComment() method
Syntax
document.createComment(
text
)
Parameters
| Parameters | Type | Description |
|---|---|---|
| text | String | Optional. The comment text to be added. |
Return Value
| Type | Description |
|---|---|
| Comment object | The created comment node |
Technical Details
| DOM version | Core Level 1 Document Object |
|---|
Document Object