<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8" name="viewport" content="width=device-width, initial-scale=1"/> <link rel="stylesheet" type="text/css" href="css/bootstrap.css"/> </head> <body> <nav class="navbar navbar-default"> <div class="container-fluid"> </div> </nav> <div class="col-md-6 well"> <hr style="border-top:1px dotted #ccc;"/> <div class="col-md-6"> <table class="table table-bordered" id="toPrint"> <thead class="alert-info"> <tr> </tr> </thead> <tbody> <tr> </tr> <tr> </tr> </tbody> </table> </div> </div> </body> </html>
function printTable() { var el=document.getElementById("toPrint"); el.setAttribute('border', '1px'); el.setAttribute('cellpadding', '5'); newPrint=window.open(""); newPrint.document.write(el.outerHTML); newPrint.print(); newPrint.close(); }