HTML DOM createComment () method
Examples
You can create a comment node, and into an HTML document:
var c=document.createComment("My personal comments");
document.body.appendChild(c);
document.body.appendChild(c);
Output:
<!--My personal comments-->
try it"
Definition and Usage
createComment () method to create a comment node.
Browser Support
All major browsers support createComment () method
grammar
document.createComment(text)
parameter
参数 | 类型 | 描述 |
---|---|---|
text | String | 可选. 添加的注释文本。 |
return value
类型 | 描述 |
---|---|
Comment object | 创建的注释节点 |
technical details
DOM version | Core Level 1 Document Object |
---|