【发布时间】:2015-07-15 08:43:59
【问题描述】:
我的页面底部有 3 个按钮,代码如下:
function printpage() {
//Get the print button and put it into a variable
var printButton = document.getElementById("printpagebutton");
//Set the print button visibility to 'hidden'
printButton.style.visibility = 'hidden';
//Print the page content
window.print()
printButton.style.visibility = 'visible';
}
#options {
align-content:center;
align-items:center;
text-align: center;
}
<div id="options">
<input type="submit" value="post news" >
<input id="printpagebutton" type="button" value="print news" onclick="printpage()"/>
<input type="button" value="re-enter the news">
</div>
我在打印时设法隐藏了打印按钮,但我不能和其他人一起。
我在互联网上搜索了解决方案,大多数问题都是通过在 css 中添加display:none; 来回答的,但我最终在屏幕上得到了 3 个隐藏按钮。
我只想在打印时隐藏按钮
答案可能很简单,我的网络开发知识很渊博。
提前谢谢你。
【问题讨论】:
-
为什么不使用媒体打印 css 文件?
-
看看@打印样式表:smashingmagazine.com/2011/11/24/…