I thought is was the <HTML> tag but that doesn’t seem to be correct. Am I missing something?
If so, is there any reason I shouldn’t give the <HTML>/$(document) an id or other attributes which I could manipulate using jQuery/Javascript?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
documentvariable refers to a memory object in JavaScript that does not correspond to anything in the HTML or the DOM tree. It is, instead, the object that contains the DOM tree. It is, in turn, contained by the Window object, which is the global object in browser-based Javascript.The
<html>element, on the other hand, is part of the DOM tree. So you can get it the same way you can get any other element, with e.g.document.getElementsByTagName('html')[0]. But since it’s the root of the DOM tree, that’s kind of silly; you can access it directly asdocument.documentElement. That works for the root of any DOM document, including XML (perhaps returned by an Ajax call). In the usual case of an HTML document, you would probably just usedocument.html. Or the jQuery equivalent.