-
-
Save nocodesupplyco/993e479f44dd0b8988523a30773b6c25 to your computer and use it in GitHub Desktop.
Print a Specific Element w/ Button
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.getElementById("print-btn").addEventListener("click", function() { | |
let printContents = document.getElementById('print-content').innerHTML; //content to print | |
let originalContents = document.body.innerHTML; | |
document.body.innerHTML = printContents; | |
window.print(); | |
document.body.innerHTML = originalContents; | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment