Get the whole document's html with JavaScript/JQuery

前端 未结 8 1116
无人及你
无人及你 2021-02-14 16:54

I know it\'s already discussed here, but there were no solution to get the whole document (including doctype).

$(document).html(); returns null

8条回答
  •  礼貌的吻别
    2021-02-14 17:20

    try this.

    $("html").html()
    

    document is a variable it dose not represent the html tag.

    EDIT

    To get the doctype one could use

    document.doctype
    

提交回复
热议问题