createComment()

创建于 2024-12-03 / 19
字体: [默认] [大] [更大]

❮ Document 对象

实例

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

var c = document.createComment("My personal comments");
document.body.appendChild(c); 亲自试一试 »

定义和用法

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


浏览器支持

方法
createComment() Yes Yes Yes Yes Yes

语法

document.createComment(text)

参数值

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

技术细节

返回值: 注释对象,表示创建的注释节点
DOM 版本 Core Level 1 Document Object

❮ Document 对象


0 人点赞过