Comment:Comment() 构造函数
Comment()
构造函数返回一个新创建的 Comment
对象,其文本内容为可选参数中给出的字符串。
语法
js
new Comment()
new Comment(aString)
参数
aString
可选
返回值
一个新的包含 aString
(如果没有给出参数,则为空字符串)的注释(Comment
)。
示例
js
let comment = new Comment("测试");
规范
Specification |
---|
DOM Standard # ref-for-dom-comment-comment① |
浏览器兼容性
BCD tables only load in the browser
参见
- DOM 接口索引
Document.createComment()
是此构造函数的一个过时替代方案。