I used $(document).html(), but that threw an error... is there a way to get everything?
Don't forget the tag can have attributes too. If you want the whole document this should work.
$('html')[0].outerHTML
It's also trivial without jQuery.
document.documentElement.outerHTML
If you also want to include the doctype, it's a little more involved.
var getDocTypeAsString = function () {
var node = document.doctype;
return node ? "\n' : '';
};
getDocTypeAsString() + document.documentElement.outerHTML