jQuery Print function to print div content with css

前端 未结 4 942
难免孤独
难免孤独 2020-12-31 09:38

I\'ve this function for my Wordpress plugin uses jQuery that prints the content from the div with class \"table_disp\". How can I print the css style along with it.

4条回答
  •  孤城傲影
    2020-12-31 10:05

    Append Stylesheet instead

    var css= '';
                var printContent = document.getElementById("printContentID");
    
                var WinPrint = window.open('', '', 'width=900,height=650');
                WinPrint.document.write(printContent.innerHTML);
                WinPrint.document.head.innerHTML = css;
                WinPrint.document.close();
                WinPrint.focus();
                WinPrint.print();
                WinPrint.close();
    

提交回复
热议问题