HOME HTML CSS JAVASCRIPT SQL PHP JQUERY XML ASP.NET MORE...
REFERENCES | EXAMPLES | FORUM | ABOUT

HTML DOM createComment() Method

Document Object Reference Document Object

Example

Create a comment node, and insert it to the HTML document:

var c=document.createComment("My personal comments");
document.body.appendChild(c);

The result will be:

<!--My personal comments-->

Try it yourself »

Definition and Usage

The createComment() method creates a Comment node with the specified text.


Browser Support

Internet Explorer Firefox Opera Google Chrome Safari

The createComment() method is supported in all major browsers.


Syntax

document.createComment(text)

Parameters

Parameter Type Description
text String Optional. The text you want to be your comment, in the Comment object

Return Value

Type Description
Comment object The created Comment node

Technical Details

DOM Version Core Level 1 Document Object


Document Object Reference Document Object


Your suggestion:

Close [X]

Thank You For Helping Us!

Your message has been sent to W3Schools.

Close [X]
Search w3schools.com:

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE