X
HOME HTML5 CSS3 JAVASCRIPT SQL PHP5 JQUERY ANGULAR BOOTSTRAP3 XML 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

Method
createComment() Yes Yes Yes Yes Yes


Syntax

document.createComment(text)

Parameter Values

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

Technical Details

Return Value: A Comment Object, representing the created Comment node
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 HOSTING

UK Reseller Hosting

WEB BUILDING

Download XML Editor FREE Website BUILDER Free HTML5 Templates

SHARE THIS PAGE

facebook