Document.documentElement
Baseline
Widely available
This feature is well established and works across many devices and browser versions. Itâs been available across browsers since 2015ë 7ì.
Document.documentElement ì½ê¸° ì ì© ìì±ì 문ìì ë£¨í¸ ìì를 ëíë´ë Element를 ë°íí©ëë¤. HTML 문ì를 ìë¡ ë¤ë©´ <html> ìì를 ë°íí©ëë¤.
구문
js
const element = document.documentElement;
ìì
js
const rootElement = document.documentElement;
const firstTier = rootElement.childNodes;
// firstTier is a NodeList of the direct children of the root element
// such as <head> and <body>
for (const child of firstTier) {
// do something with each direct child of the root element
}
ì°¸ê³
모ë ë¹ì´ìì§ ìì HTML 문ìì documentElementë íì <html> ìì를 ê°ë¦¬íµëë¤. 모ë ë¹ì´ìì§ ìì XML 문ìì documentElementë ì¢
ë¥ë¶ë¬¸íê³ í´ë¹ 문ìì ë£¨í¸ ìì를 ê°ë¦¬íµëë¤.
ëª ì¸
| Specification |
|---|
| DOM > # ref-for-dom-document-documentelementâ > |