您好,我需要打印一份没有按钮的文档。谁能指导我完成这项任务。
我在按钮单击 onclick() 事件中有一个要打印的按钮 我已经使用 window.print() 打印这些数据。但是在打印预览中它显示了包含这 4 个按钮的页面。我不想要那些按钮我只需要那些数据。
有关更多信息,我添加了下面的图片
最佳答案
为不可打印的东西添加一个包装器,即你案例中的按钮。检查以下代码:
<head>
<style type="text/css">
#printable {
display: none;
}
@media print {
#non-printable {
display: none;
}
#printable {
display: block;
}
}
</style>
</head>
<body>
<div id="non-printable">
Your normal page contents
</div>
<div id="printable">
Printer version
</div>
</body>
希望对您有所帮助。
关于javascript - 使用javascript打印文档,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/28580383/