【发布时间】:2017-07-29 18:13:29
【问题描述】:
我有以下 JavaScript 代码来打印内容
<script type="text/javascript">
function Print(print)
{
Popup($(print).html());
}
function Popup(data)
{
var mywindow = window.open("", "print");
mywindow.document.write("<html><head><title>Report</title>");
mywindow.document.write("</head><body>");
mywindow.document.write("<div align='center'>");
mywindow.document.write(data);
mywindow.document.write("</div>");
mywindow.document.write("</body></html>");
mywindow.print();
mywindow.close();
return true; }
</script>
在我的 HTML 中,我有以下代码:
<html>
<body>
<p><a href="javascript:Print('#print')">Print</a></p>
<div id="print">
<h1>Report</h1>
<table>
<tr><th>Date</th><th>Remarks</th><th>Amount</th><th>Actions</th></tr>
<tr>
<td>10/11/2014</td>
<td>Hello</td>
<td>$14</td>
<td>Edit</td>
</tr>
</table>
</div>
</body>
</html>
我只想打印前 3 列。我不想打印第 4 列“操作”。当我尝试使用上面的代码打印出内容时,它会打印所有 4 列。请帮我解决以下问题。
【问题讨论】:
标签: javascript html mysql printing html-table