How to hide print button while printing?

后端 未结 5 1473
悲&欢浪女
悲&欢浪女 2021-01-23 05:57

I want to print the page on button click without opening a new tab.

I have a following lines of code that does the job for me.

function PrintDiv() {    
         


        
相关标签:
5条回答
  • 2021-01-23 06:31

    You need @media print in you css. Just add this at your bottom ofyour CSS file,

    @media print {
        #print {display: none;}
    }
    
    0 讨论(0)
  • 2021-01-23 06:38

    Hi you can use below methods,

    $('#PrintDiv').hide();
    

    or

    $('#PrintDiv').prop('disabled', 'true');
    

    or

     @media print{
        #PrintDiv{
            display:none !important;
        }
    }
    
    0 讨论(0)
  • 2021-01-23 06:42

    Simply use a media query to hide when printing

    @media print {
       #button-container{
          display: none;
       }
    }
    
    0 讨论(0)
  • 2021-01-23 06:54

    You need to have a print based CSS style rule - you can also set other print based rules - such as document size, background color , image specs etc:

    @media print {
       #button-container{
          display: none;
       }
    }
    
    0 讨论(0)
  • 2021-01-23 06:54

      <div id="button-container">
         <a href="#" id="PrintDiv" class="btn btn-success btn-primary" style="visibility:block;"><span class="glyphicon glyphicon-print"n aria-hidden="true"></span>Print</a> </div>

    document.getElementById('PrintDiv').style.visibility = 'hidden';

    document.getElementById('PrintDiv').style.visibility = 'hidden';

    0 讨论(0)
提交回复
热议问题