jquery removes html and body since there can only be one html and body in a document. The Brian answer is the closest you can get, but only in a browser without IE, since IE does not parse the tag without html.
For instance:
var test = "<test>This is it</test>"; alert($(test).html()); // display This is it in non IE browser (working in 8-9?).
EDIT: How about replacing html and body with div class = html / body?
var test = "<html><body><div>this is a test</div></body></html>"; test = test.replace(/(\/body|\/html)/i, "\/div") .replace(/html/i, "div class='html'") .replace(/body/i, "div class='body'"); console.log($(test));
source share