用于清除整个DOM的最小JS源代码 [英] minimal JS sources for wiping out the whole DOM

查看:150
本文介绍了用于清除整个DOM的最小JS源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这最初来自 https://stackoverflow.com/q/45390025/1737973。

有时,当浏览器支持并启用JS时,我发现重建大多数DOM更为有用(特别是在 body tag),而不是风格,并赋予它生命和RIA。

Sometimes, when JS is supported and enabled in the browser, I find it more useful to rebuild most the DOM (notably under the body tag) from scratch, rather than style and give life and RIA to it.

vanilla JS消息来源以简洁,简短而有效的方式清除 body 标记下的所有DOM?

Which are the vanilla JS sources for wiping out all DOM under the body tag in a concise, short yet efficient way?

推荐答案

document.body.innerHTML = ""
document.head.innerHTML=""

...但为什么?

这篇关于用于清除整个DOM的最小JS源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆