# document.write和document.insert区别

document.write和document.insert区别

document对象也就是这个html文档的对象,当html页面被加载到浏览器中所对应的对象就是document对象。

document.write在文档加载完成以后调用会覆盖整个文档,但在文档加载过程中调用的话就会插入到文档当中,如果是多次调用document.wirte的话,文本会合并。

insertdocument.write区别有:

  • insert方法不是docuemnt对象所独有的,其他的dom对象都可以使用
  • insert调用会清除原本的内容,多个insert的调用会使用最后一次insert的内容

猜你喜欢

转载自www.cnblogs.com/freesfu/p/11516706.html
今日推荐