我有一个打印页面按钮,但点击一次后它不起作用。这是我的代码
$('body').css('overflow', 'hidden');
$('html').animate({ scrollTop: 0 }, 'fast', 'swing', function () {
var printContents = document.getElementById("shipping-reservation-
summary").innerHTML;
var originalContents = document.body.innerHTML;
document.body.innerHTML = printContents;
window.print();
document.body.innerHTML = originalContents;
return false;
})
只需隐藏您不想打印的div
const printDiv = () => {
for (const element of document.getElementsByClassName('invoice-actions')) {
element.style.display = 'none';
}
window.print();
for (const element of document.getElementsByClassName('invoice-actions')) {
element.style.display = 'block';
}
return false;
};