dom_dom0200_001

DOMツリーの最上位にあるオブジェクトは( A )であり、その直下のルート要素は通常 ( B ) プロパティで参照できる。

解答

A: Document
B: document.documentElement

解説

ブラウザはページを Document オブジェクトとして扱い、その中にHTML全体のルート要素(通常は <html>)がぶら下がる。document.documentElement はそのルート要素を返す。

使用例(サンプルコード)

[ js ]

console.log(document instanceof Document); // true
console.log(document.documentElement.tagName); // "HTML"