title: Print html through JavaScript / jQuery
body: <p>I wish to print a document by passing custom html code.</p>
  
  <p>The non-working code I have written :</p>
  
  <pre><code>function Clickheretoprint()
  {
    var disp_setting="toolbar=yes,location=no,directories=yes,menubar=yes,"; 
        disp_setting+="scrollbars=yes,width=780, height=780, left=100, top=25"; 
    var content_vlue = document.getElementById("result_tbl").innerHTML; 
  
    var docprint=window.open("","",disp_setting); 
    docprint.document.open(); 
    docprint.document.write('&lt;html&gt;&lt;head&gt;&lt;title&gt;Ashley Mattresses&lt;/title&gt;'); 
    docprint.document.write('&lt;/head&gt;&lt;body onLoad="self.print()"&gt;&lt;center&gt;');          
    docprint.document.write('&lt;TABLE width="100%" cellpadding=10 align=center  valign="top"&gt;&lt;TR valign="top"&gt;&lt;TD width = "33%" valign="top"&gt;col1&lt;/TD&gt;&lt;TD width = "33%" valign="top"&gt;col2&lt;/TD&gt;&lt;TD width = "33%" valign="top"&gt;col3&lt;/TD&gt;&lt;/TR&gt;&lt;/TABLE&gt;');     
    docprint.document.write('&lt;/center&gt;&lt;/body&gt;&lt;/html&gt;'); 
    docprint.document.close(); 
    docprint.focus(); 
    docprint.close();
  }
  </code></pre>
  
  <p>This is the method I called on href of an anchor tag, but the not getting the work done:</p>
  
  <pre><code>&lt;a href="javascript:Clickheretoprint()"&gt;
  </code></pre>
  
  <p>I am a beginner to JavaScript/jQuery coding.</p>