Is it possible to parse a complete HTML document as a complete jQuery object? When I try, e.g.
var $tmp = $("<html><head><title>title</title></head><body><p id='test'>test</p></body></html>");
console.log($tmp);
I get:
[+] [title, p#test] []
i.e. an array combining all of the head’s children with all of the body’s. Is it not possible to retain the structure, including the html, head, and body elements?
jquery strips out html and body as there can only be one html and body in a document. Brian’s answer is the closest you can get, but only on non IE browser as IE don’t parse non html tag.
For example:
EDIT:
How about replacing html and body with div class=html/body?