[go: up one dir, main page]

此页面由社区从英文翻译而来。了解更多并加入 MDN Web Docs 社区。

View in English Always switch to English

Comment:Comment() 构造函数

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since ⁨2017年10月⁩.

Comment() 构造函数返回一个新创建的 Comment 对象,其文本内容为可选参数中给出的字符串。

语法

js
new Comment()
new Comment(aString)

参数

  • aString 可选

返回值

一个新的包含 aString(如果没有给出参数,则为空字符串)的注释(Comment)。

示例

js
let comment = new Comment("测试");

规范

Specification
DOM
# ref-for-dom-comment-comment①

浏览器兼容性

参见