Get the name of the document element node:
document.documentElement.nodeName;
Try it Yourself »
The documentElement
property returns a document's element (as an Element object).
The documentElement
is read-only.
For HTML documents the returned object is the <html> element.
The difference between document.body and document.documentElement:
document.body returns the <body> element
document.documentElement returns the <html> element.
document.documentElement
Type | Description |
Object | The document's Element Object |
document.documentElement()
is a DOM Level 1 (1998) feature.
It is fully supported in all browsers:
Chrome | Edge | Firefox | Safari | Opera | IE |
Yes | Yes | Yes | Yes | Yes | 9-11 |
截取页面反馈部分,让我们更快修复内容!也可以直接跳过填写反馈内容!