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() {
You need @media print
in you css. Just add this at your bottom ofyour CSS file,
@media print {
#print {display: none;}
}
Hi you can use below methods,
$('#PrintDiv').hide();
or
$('#PrintDiv').prop('disabled', 'true');
or
@media print{
#PrintDiv{
display:none !important;
}
}
Simply use a media query to hide when printing
@media print {
#button-container{
display: none;
}
}
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;
}
}
<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';