Skip to content

Noob question about runtime and DOM stuff #597

Closed Answered by vlwkaos
ShrimpTacos314 asked this question in Content
Discussion options

You must be logged in to vote

document is a property of host object window which is a global object of a browser. The document object refers to the HTMLdocument object of the currently opened html file. And as HTML has a structure of head and body, you can access body element as a property of document object and this is just how the object is implemented by specification. (correct me if I am wrong). The document do hold the HTMLElement you appended to the body, but not a direct reference to it. You might want to open a console F12 and type in document and expand on it to see the properties.

So if you try to access bar from document, it is not there since it is not a property of the document object.
If you create an el…

Replies: 2 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by pepelsbey
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
3 participants