自强学堂
自强学堂:学习、分享、让你更强!
JavaScript 参考手册HTMLCSSJAVASCRIPTJQUERYSQLPHPBOOTSTRAPANGULARXML
 

HTML DOM createComment() 方法

Document 对象参考手册 Document 对象

实例

可创建注释节点, 并插入HTML文档:

var c=document.createComment("My personal comments");
document.body.appendChild(c);

输出结果:

<!--My personal comments-->

尝试一下 »

定义和用法

createComment() 方法可创建注释节点。


浏览器支持

Internet ExplorerFirefoxOperaGoogle ChromeSafari

所有主要浏览器都支持 createComment() 方法


语法

document.createComment(text)

参数

参数类型描述
textString可选. 添加的注释文本。

返回值

类型描述
Comment object创建的注释节点

技术细节

DOM 版本Core Level 1 Document Object


Document 对象参考手册 Document 对象