I tried printing a particular div on a dynamic webpage which is a php file.
2
you can use
echo '<div></div>';
to print a div you can use:
<div id="print-div"> ...content of div goes here... </div>
add this function
function printDiv() { var printDiv = document.getElementById("print-div"); var printContent = printDiv.innerHTML; var printWindow = window.open("", "", "width=800,height=600"); printWindow.document.write(printContent); printWindow.print(); printWindow.close(); }
and try with this button
<button onclick="printDiv()">Test Print Div</button>
Click here to cancel reply.
2
Answers
you can use
to print a div you can use:
add this function
and try with this button