title: Print a div content using Jquery
body: <p>I want to print the content of a div using jQuery. This question is already asked in SO, but I can't find the correct (working) answer.</p>
  
  <p>This is is my HTML:</p>
  
  <pre><code>&lt;div id='printarea'&gt;
      &lt;p&gt;This is a sample text for printing purpose.&lt;/p&gt;
      &lt;input type='button' id='btn' value='Print'&gt;
  &lt;/div&gt;
  &lt;p&gt;Do not print.&lt;/p&gt;
  </code></pre>
  
  <p>Here I want to print the content of the div <code>printarea</code>. </p>
  
  <p>I tried this:</p>
  
  <pre><code>$("#btn").click(function () {
      $("#printarea").print();
  });
  </code></pre>
  
  <p>But it gives a console error when the button is clicked:</p>
  
  <blockquote>
    <p>Uncaught TypeError: $(...).print is not a function</p>
  </blockquote>
  
  <p>But when I am trying to print the entire page using</p>
  
  <pre><code>window.print();
  </code></pre>
  
  <p>it is working. But I only want to print the content of a particular div. I saw the answer <code>$("#printarea").print();</code> in many places , but this is not working.</p>