Last active
April 12, 2016 10:59
-
-
Save junquera/6ad76839a9c40f88198b to your computer and use it in GitHub Desktop.
Print web element
This file contains hidden or 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 padToThree(number) { | |
| if (number<=9999) { number = ("00"+number).slice(-3); } | |
| return number; | |
| } | |
| function printDiv(divId) { | |
| var printContents = $(divId).html(); | |
| var originalContents = document.body.innerHTML; | |
| document.body.innerHTML = "<html><head><title></title></head><body>" + printContents + "</body>"; | |
| window.print(); | |
| document.body.innerHTML = originalContents; | |
| } | |
| var divToPrint = document.createElement('div'); | |
| divToPrint.setAttribute('id', 'imprime'); | |
| for(var i = 0; i < $('.slide_image').length; i++){ | |
| var pag = $($('.slide_image')[i]).attr('data-full'); | |
| var img = document.createElement('img'); | |
| $(img).attr('src', pag); | |
| $(divToPrint).append(img); | |
| } | |
| document.body.appendChild(divToPrint); | |
| printDiv('#imprime'); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment