小白教程
所有教程
关于
Search
172.69.7.165
172.69.7.165
参数设置
贡献
退出
操作
编辑
移动
保护
信息
历史
删除
查看“Met document createcomment”的源代码
本页内容
上一节:
Met_document_createattribute
下一节:
Met_document_createdocumentfragment
因为以下原因,您没有权限编辑本页:
您请求的操作仅限属于该用户组的用户执行:
用户
您可以查看和复制此页面的源代码。
{{DISPLAYTITLE:document.createComment()}}[[Category:dom obj document|10]] = HTML DOM createComment() 方法 = [[dom obj document|Document 对象]] 可创建注释节点, 并插入HTML文档: <sample title="" desc="" lang="html" hererun="1"> var c=document.createComment("My personal comments"); document.body.appendChild(c); </sample> 输出结果: <sample title="" desc="" lang="html" hererun="1"> <!--My personal comments--> </sample> <run name=""> <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>小白教程(xiaobai.wang)</title> </head> <body> <p id="demo">单击按钮改HTML文档添加一个注释</p> <button onclick="myFunction()">点我</button> <script> function myFunction(){ var c=document.createComment("My personal comments"); document.body.appendChild(c); var x=document.getElementById("demo"); x.innerHTML="这个文件现在包含一个注释,但如你所知,注释是看不见的。"; }; </script> </body> </html> </run> == 定义和用法 == createComment() 方法可创建注释节点。 == 浏览器支持 == 所有主要浏览器都支持 createComment() 方法 == 语法 == <pre> document.createComment(text)</pre> == 参数 == {| class="table table-striped table-hover" ! 参数 ! 类型 ! 描述 |- | text | String | 可选. 添加的注释文本。 |} == 返回值 == {| class="table table-striped table-hover" ! 类型 ! 描述 |- | Comment object | 创建的注释节点 |} == 技术细节 == {| class="table table-striped table-hover" | DOM 版本 | Core Level 1 Document Object |} [[dom obj document|Document 对象]]
返回至“
Met document createcomment
”。
上一节:
Met_document_createattribute
下一节:
Met_document_createdocumentfragment