Click here to Skip to main content
15,918,193 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi All,

I tried to hide a some images while printing a page in button click event. But, I'm not able to hide. can any one please help.



Thanks & Regards,

IsaiSelvan. S

What I have tried:

I tried to hide a some images while printing a page in button click event. But, I'm not able to hide. can any one please help.

<link href="css/print.css" rel="stylesheet" type="text/css" />
<title></title>
<script type="text/javascript">
function print_btn() {
// var print_window = window.open('', '');
// print_window.document.write('<html>', '<head>');
// print_window.document.write('</head>', '<body>');
// print_window.document.write('</body>', '</html>');
// print_window.print();
// print_window.focus();
// print_window.setAttribute('style', 'display: none;');
//document.getElementById('footer').style.display = 'none';
//var btnctrl = document.getElementById("btn_click");
window.print();
}
Posted
Updated 8-Mar-16 18:47pm

1 solution

Use @media print in CSS like below:
CSS
@media print
{    
    .noPrint
    {
        display: none !important;
    }
}

Then add class to image, it will hide at the time of printing:
HTML
<img src="test.png" class="noPrint" id="imgtest" />
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900