Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

HTML DOM createComment() method

HTML DOM createComment() method

Document Object Reference Document Object

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

Internet ExplorerFirefoxOperaGoogle ChromeSafari

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 Reference Document Object