title: How to print table using Javascript?
body: <p>I found this code to print in Javascript.</p>
  
  <pre><code>function printData()
  {
     var divToPrint=document.getElementById("printTable");
     newWin= window.open("");
     newWin.document.write(divToPrint.outerHTML);
     newWin.print();
     newWin.close();
  }
  </code></pre>
  
  <p>The element ID "printTable" is the ID of the table that I want to print but unfortunately it only prints out the contents of the table and not the style of the table. I just want to have borders on it so that it is easier to read in print. Can anyone help me? </p>