Jquery 在某些HTML标记之后停止打印
我已经编写了以下脚本来打印页面 是否可以不在以下标记后打印HTMLJquery 在某些HTML标记之后停止打印,jquery,css,Jquery,Css,我已经编写了以下脚本来打印页面 是否可以不在以下标记后打印HTML <font class="productnamecolorSMALL colors_productname"><b>Related Items</b></font> 相关项目 意思是忽略上面的打印 <p>Click the button to print the current page.</p> <button onclick="my
<font class="productnamecolorSMALL colors_productname"><b>Related Items</b></font>
相关项目
意思是忽略上面的打印
<p>Click the button to print the current page.</p>
<button onclick="myFunction()">Print this page</button>
<script>
function myFunction() {
window.print();
}
</script>
单击按钮打印当前页面
打印此页
函数myFunction(){
window.print();
}
正如Alexis Wilke建议的那样,添加打印样式表
此css将使用相邻同级选择器从打印页面中删除.productnamecolorSMALL的第一个相邻同级。您可以使用任何css来标记要删除的内容,或在打印时以不同方式显示。因此,只需根据需要编辑打印样式表
html
我不认为
print()
函数会允许这样做,尽管如果你把它做成一个块,比如某个
,当@media
类型为print
时,你可能会用display:none
标记该部分。使用具有这些属性的CSS样式表。
<link rel="stylesheet" media="print" href="/css/print.css" type="text/css" />
@media print{
.productnamecolorSMALL+*{
display: none;
}
}