HTML DOM createComment() 方法

[

HTML DOM createComment() 方法
Document 对象

实例

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


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

	document.body.appendChild(c);

输出结果:


<!--My personal comments-->

定义和用法

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

浏览器支持

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

语法

document.createComment(text)

参数

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

返回值

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

技术细节

DOM 版本 Core Level 1 Document Object

Document 对象

]
转载请保留页面地址:https://www.breakyizhan.com/html/21397.html
原文地址:https://www.cnblogs.com/breakyizhan/p/13263456.html