Print HTML content onclick by ID.

<span class="glyphicon glyphicon-print" onclick="printDiv('yourdiv')"></span> <script> function printDiv(divName) { var printContents = document.getElementById(divName).innerHTML; var originalContents = document.body.innerHTML; document.body.innerHTML = printContents; window.print(); document.body.innerHTML = originalContents; } </script>
Just change "yourdiv" with your created div and it will print that div onclick. If your print is not getting proper then add a print.css file with print oriented CSS. Ping me if you find any difficulty. :)

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.