how to print a Div content in javascript

By using this script we can print the content of a Div. It is working fine.
We have to call this script like this:

<button onclick="printContent(print_div_id)">Print</button>

 function printContent(el)
 var restorepage = document.body.innerHTML;
 var printcontent = document.getElementById(el).innerHTML;
 document.body.innerHTML = printcontent;
 document.body.innerHTML = restorepage;

Leave a Reply

Your email address will not be published. Required fields are marked *