This page is Almost Ready

Notice: The WebPlatform project, supported by various stewards between 2012 and 2015, has been discontinued. This site is now available on github.

createComment

Summary

Creates a comment object with the specified data.

Method of dom/Documentdom/Document

Syntax

var commentNode = document.createComment(text);

Parameters

text

Data-type
String

Text of the comment.

Return Value

Returns an object of type DOM NodeDOM Node

The created comment node.

Examples

//create a comment node
var cmt = document.createComment("Comment text");
//add the comment to the document body
document.body.appendChild(cmt);

Related specifications

DOM Level 3 Core
Recommendation

Attributions