怎样创建并插入一个注释节点

使用document.createComment().

document.body.prepend(document.createComment('helloworld'));

如上所示, 我们在body子元素顶部增加了一个注释节点: <!--helloworld-->

 

posted on 2019-09-18 23:57  aisowe  阅读(423)  评论(0编辑  收藏  举报

导航