Is it too lame to write like this?
var html = $('html');
Seems that html is equal to $(window) or $(document)?
How can it be replaced by a crossbrowser native 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 top-level element (
htmlin the case of HTML documents) is available asdocument.documentElement(references: spec | MDN).And of course, if you want to use jQuery stuff on it, get a jQuery wrapper:
$(document.documentElement).In terms of cross-browser support, I’d be fairly shocked if you found anything even vaguely recent that didn’t support it (and that includes IE6), it was actually in DOM1, which was a long time ago. See this related question on that very topic.