Create a comment node, and insert it to the HTML document:
The result will be:
The createComment() method creates a Comment node with the specified text.
![]()
The createComment() method is supported in all major browsers.
| Parameter | Type | Description |
|---|---|---|
| text | String | Optional. The text you want to be your comment, in the Comment object |
| Type | Description |
|---|---|
| Comment object | The created Comment node |
| DOM Version | Core Level 1 |
|---|
Your message has been sent to W3Schools.