Created
August 19, 2019 03:26
-
-
Save parzibyte/5444a80c8dd7c76781bf33deceb2ee71 to your computer and use it in GitHub Desktop.
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
/* | |
Imprimir solo algunos elementos | |
con JavaScript y CSS | |
@author parzibyte | |
https://parzibyte.me/blog | |
*/ | |
const $btnImprimir = document.querySelector("#btnImprimir"); | |
$btnImprimir.addEventListener("click", () => { | |
let ocultos = document.querySelectorAll("p,strong,h1,h2,a,button,img"); | |
ocultos.forEach(elemento => { | |
elemento.classList.add("oculto-impresion"); | |
}); | |
let mostrados = document.querySelectorAll(".forzar-impresion"); | |
mostrados.forEach(elemento => { | |
elemento.classList.remove("oculto-impresion"); | |
}); | |
window.print(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment