javascript打印仅特定的内容< div> [英] javascript to print contents of only specific <div>
本文介绍了javascript打印仅特定的内容< div>的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经尝试过javascript window.print()
它打印整页内容,包括页面上的打印按钮。
I have tried javascript window.print()
It prints the full page content including the print button on the page.
推荐答案
您需要创建新的样式表print.css并设置 CSS media = print
You require to create new style sheet print.css and set CSS media=print
例如:
<style media="screen">
.noPrint{ display: block; }
.yesPrint{ display: block !important; }
</style>
<style media="print">
.noPrint{ display: none; }
.yesPrint{ display: block !important; }
</style>
了解详情:使用CSS打印文字
这篇关于javascript打印仅特定的内容< div>的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文