使用document.createComment().

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

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

 

评论关闭
IT源码网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!