Skip to content

Instantly share code, notes, and snippets.

@luzfcb
Forked from rg3915/print.js
Created March 17, 2018 16:05
Show Gist options
  • Save luzfcb/5b65cc38c41a43cf7999be48e9b33b75 to your computer and use it in GitHub Desktop.
Save luzfcb/5b65cc38c41a43cf7999be48e9b33b75 to your computer and use it in GitHub Desktop.
Print on HTML with JS
<script>
function printDiv(divName) {
var printContents = document.getElementById(divName).innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
}
</script>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment