Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get HTML element similar to getting BODY with document.body? [duplicate]

Tags:

javascript

dom

I know there's a way to do this, but I cannot recall how.

How do I go about grabbing the HTML element (top-most element in the DOM), using plain JavaScript?

like image 389
Zoolander Avatar asked Sep 02 '11 21:09

Zoolander


1 Answers

Use document.documentElement.

See the docs: https://developer.mozilla.org/en-US/docs/Web/API/Document/documentElement

like image 180
Digital Plane Avatar answered Nov 02 '22 23:11

Digital Plane