Created
May 22, 2016 10:24
-
-
Save Chukatuk/4185a7e19c34ffb58775c0aad7b6a1d0 to your computer and use it in GitHub Desktop.
Print a specific DIV with custom page style
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
$('.print').click(function(){ | |
var div = $('.entry').html(); | |
var title = $('h1').text(); | |
console.log(); | |
var mywindow = window.open('', '', 'height=800,width=1000'); | |
mywindow.document.write('<html><head><title>'+title+'</title>'); | |
mywindow.document.write('<style></style>'); | |
mywindow.document.write('</head><body >'); | |
mywindow.document.write(div); | |
mywindow.document.write('</body></html>'); | |
mywindow.document.close(); // necessary for IE >= 10 | |
mywindow.focus(); // necessary for IE >= 10 | |
mywindow.print(); | |
mywindow.close(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment