我看到了这个答案,但是如何继续从第二个、第三个 div 打印文本?这就是我想要的:
<script type="text/javascript">
function PrintElem(elem)
{
Popup($(elem).text());
}
function Popup(data)
{
var mywindow = window.open('', 'Coupon', 'height=300,width=710');
mywindow.document.write('<html><head><title>Coupon</title>');
/*optional stylesheet*/ mywindow.document.write('<link rel="stylesheet" href="cupon.css" type="text/css" />');
mywindow.document.write('</head><body ><div class="coupon_logo"><img src="discount.jpg"></div><div class="coupon_conditions">');
mywindow.document.write(data); // text from first div
mywindow.document.write('</div>');
mywindow.document.write('<div class="coupon_clinic_info">');
//text from second div
mywindow.document.write('</div>');
mywindow.document.write('</body></html>');
mywindow.print();
mywindow.close();
return true;
}