Comment 接口代表标签(markup)之间的文本符号(textual notations)。尽管它通常不会显示出来,但是在查看源码时可以看到它们。在 HTML 和 XML 里,注释(Comments)为 '<!--' 和 '-->' 之间的内容。在 XML 里,注释中不能出现字符序列 '--'。

属性

该接口没有特定的属性,但是从其父类 CharacterData 继承属性,以及间接从 Node 继承部分属性。

构造函数

Comment()
使用文本内容作为参数,返回一个 Comment 对象。

方法

该接口没有特定的方法,但从其父类 CharacterData 继承方法,以及间接从 Node 继承部分方法。

规范

Specification Status Comment
DOM
Comment
Living Standard Added the constructor.
Document Object Model (DOM) Level 3 Core Specification
Comment
Obsolete No change from Document Object Model (DOM) Level 2 Core Specification
Document Object Model (DOM) Level 2 Core Specification
Comment
Obsolete No change from Document Object Model (DOM) Level 1 Specification
Document Object Model (DOM) Level 1 Specification
Comment
Obsolete Initial definition

浏览器兼容性

Update compatibility data on GitHub
DesktopMobile
ChromeEdgeFirefoxInternet ExplorerOperaSafariAndroid webviewChrome for AndroidFirefox for AndroidOpera for AndroidSafari on iOSSamsung Internet
CommentChrome Full support 1Edge Full support YesFirefox Full support 1IE Full support YesOpera Full support YesSafari Full support YesWebView Android Full support YesChrome Android Full support YesFirefox Android Full support YesOpera Android Full support YesSafari iOS Full support YesSamsung Internet Android ?
Comment() constructor
Experimental
Chrome Full support YesEdge Full support YesFirefox Full support 24IE No support NoOpera Full support YesSafari ? WebView Android Full support YesChrome Android Full support YesFirefox Android Full support 24Opera Android Full support YesSafari iOS ? Samsung Internet Android ?

Legend

Full support  
Full support
No support  
No support
Compatibility unknown  
Compatibility unknown
Experimental. Expect behavior to change in the future.
Experimental. Expect behavior to change in the future.

参见

文档标签和贡献者

标签: 
此页面的贡献者: RainSlide, mdnwebdocs-bot, AshfaqHossain, AlexChao
最后编辑者: RainSlide,