I know it\'s already discussed here, but there were no solution to get the whole document (including doctype).
$(document).html(); returns null
$(document).html();
null
I have done it on browser's console
document.documentElement;