createComment()方法创建具有指定文本的注释节点。
document.createComment(text)
var c = document.createComment("这是一个注释");
document.body.appendChild(c);测试看看‹/›所有浏览器完全支持createComment()方法:
| Method | ![]() | ![]() | ![]() | ![]() | ![]() |
| createComment() | 是 | 是 | 是 | 是 | 是 |
| 参数 | 描述 |
|---|---|
| text | 包含要添加到注释中的文本的字符串 |
| 返回值: | 表示创建的Comment节点的Comment对象 |
|---|---|
| DOM版本: | DOM级别1 |