Created
June 20, 2022 19:41
-
-
Save jrichardsz/f83ddbb97302e50d178c086a7818d78d to your computer and use it in GitHub Desktop.
print div html
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
function printDiv(divName) { | |
var printContents = document.getElementById(divName).innerHTML; | |
var originalContents = document.body.innerHTML; | |
document.body.innerHTML = printContents; | |
window.print(); | |
document.body.innerHTML = originalContents; | |
} | |
function printDivByClass(classes) { | |
var printContents = document.getElementsByClassName(classes)[0].innerHTML; | |
var 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