我的 html 代码中有 2 个 div 标签。并且页面顶部有 1 个打印按钮。当我单击打印按钮时,它会为我提供打印 html 页面上的所有内容(意味着来自两个页面的内容) div)。我想限制此打印按钮的功能,直到仅第一个 div,并且我将在下一个 div 之前添加另一个打印按钮以独立打印该 div 内容。我有什么办法可以做到这一点吗?
<html>
<body>
<input type="button" value="Print" class="noprint" onclick="window.print();return false;">
<div>
...
//my content.Want to print only this div when I will click print button.
...
</div>
//I will add another print button here which will allow me to print the next div.
<div>
...
//my content
...
</div>
</body>
</html>
@media print {
*
{
display: none !important;
}
.printable
{
display: block !important;
}
}
然后将可打印类添加到要打印的 div 中。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)