How do I get the entire page's HTML with jQuery?

后端 未结 5 722
有刺的猬
有刺的猬 2020-11-27 04:45

I used $(document).html(), but that threw an error... is there a way to get everything?

5条回答
  •  刺人心
    刺人心 (楼主)
    2020-11-27 05:00

    You could try:

    $("html").html();
    

    If you want to also capture the html tags you could concatenate them to the html like this:

    function getPageHTML() {
      return "" + $("html").html() + "";
    }
    

提交回复
热议问题