如何获得类似于通过document.body获取BODY的HTML元素? [英] How to get HTML element similar to getting BODY with document.body?
本文介绍了如何获得类似于通过document.body获取BODY的HTML元素?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我知道有办法做到这一点,但我不记得要怎么做。
I know there's a way to do this, but I cannot recall how.
如何获取HTML元素(DOM中最顶部的元素) ),使用普通JavaScript?
How do I go about grabbing the HTML element (top-most element in the DOM), using plain JavaScript?
推荐答案
使用 document.documentElement
。
请参阅文档: https:// developer .mozilla.org / en / document.documentElement
这篇关于如何获得类似于通过document.body获取BODY的HTML元素?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文