Have tried many ways to print a div, but this is the simplist and cleanest way to do it.
You can hide anything you want prior to the printing….
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 |
<input type="button" onclick="myprint()" class="print" value="PRINT" /> <script> function myprint() { $('.back').hide(); //this will hide buttons before printing $('.print').hide(); //this will hide buttons before printing var divToPrint=document.getElementById("page-wrapper"); newWin= window.open(""); newWin.document.write(divToPrint.outerHTML); newWin.print(); newWin.close(); $('.back').show(); //this will show the buttons again after printing! $('.print').show(); } </script> |