Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>Remove <code>document.getElementById('print').style.display='none';</code> from your <code>printpage()</code> function.</p> <p>In the above case the button will be visible for another click event but when you will print the document, the button will be shown on printed document. Am I right?</p> <p>To prevent printing the <code>print</code> button you need to use <a href="http://www.w3.org/TR/css3-mediaqueries/" rel="nofollow">css media queries</a> <code>@media print</code></p> <p><strong>Add following in your extrernal stylesheet OR in <code>&lt;style&gt;</code> tag inside a <code>&lt;head&gt;</code> tag of the HTML page:</strong></p> <pre><code> @media print { .noprint { display: none; } }​ </code></pre> <p>and add <code>.noprint</code> class on</p> <pre><code>&lt;input name="print" class="noprint" type="submit" id="print" value="PRINT" onclick="printpage()" /&gt; </code></pre> <p><a href="http://jsfiddle.net/akhurshid/wR76u/" rel="nofollow"><strong>SEE DEMO</strong></a></p> <p>It will print the document without printing the button and your button will also be visible for the second time click :-)</p> <p><strong>EDITED:</strong></p> <p><strong>USE HTML AS GIVEN BELOW:</strong></p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset=utf-8 /&gt; &lt;title&gt;JS Bin&lt;/title&gt; &lt;!-- Your Stylesheet (CSS) --&gt; &lt;style type="text/css"&gt; @media print { .noprint { display: none; } }​ &lt;/style&gt; &lt;!-- Your Javascript Function --&gt; &lt;script&gt; function printpage() { window.print(); } &lt;/script&gt; &lt;/head&gt; &lt;body&gt; &lt;!-- Your Body --&gt; &lt;p&gt;Only This text will print&lt;/p&gt; &lt;!-- Your Button --&gt; &lt;input class="noprint" type="button" value="PRINT" onclick="printpage()" /&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p><a href="http://jsbin.com/otihov/1/edit" rel="nofollow"><strong>SEE ABOVE CODE IN ACTION</strong></a></p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload