dom_dom0200_007

ドキュメント内の <head> と <body> は、それぞれ ( A ) と ( B ) プロパティで簡単に参照できる。

解答

A: document.head
B: document.body

解説

document.head と document.body は頻出ショートカット。document.documentElement から辿るより簡潔に目的の要素へアクセスできる。

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

[ js ]

console.log(document.head.tagName); // "HEAD"
console.log(document.body.tagName); // "BODY"