我想通过使用jquery按下打印按钮来打印表格,但应用于表格的样式不起作用。 这里是我的CSS使用jquery按下打印按钮时,css样式不适用
<style>
table {border-collapse:collapse;}
table td, table th{ border: 1px solid #73afb7; text-align:left;}
</style>
jQuery代码
$(document).ready(function() {
$('#print').click(function(){
var divContents = $('#abc').html();
var printWindow = window.open('', '', ',width=800');
printWindow.document.write('<html>');
printWindow.document.write('<body >');
printWindow.document.write(divContents);
printWindow.document.write('</body></html>');
printWindow.print();
printWindow.close();
});//end of print button click
});//end of ready function
HTML
<div id="abc">
<table id="tbl">
<tr>
<th>S.No</th>
<th>NAME</th>
</tr>
<tr>
<td>1</td>
<td>AYAZ</td>
</tr>
</table>
</div>
当按下打印按钮jquery的印刷品没有边界的表格内容
在你的jQuery代码中,你使用'window'创建一个新窗口。打开“,那么新窗口与主窗口是分开的,不会共享它的CSS。 – AeroX