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
Microsoft Developer Network: [Windows Internet Explorer API reference Article]