<script>
function printDiv(divId) {
var printContents = document.getElementById(divId).innerHTML;
var newWindow = window.open('', '', 'width=1000,height=800');
newWindow.document.write('<html><head><title>打印</title>');
newWindow.document.write('</head><body>');
newWindow.document.write(printContents);
newWindow.document.write('</body></html>');
newWindow.document.close();
newWindow.focus();
newWindow.print();
newWindow.close();
}
</script>
<div id="printableArea">
打印内容。
</div>
<button type="button" onclick="printDiv('printableArea')" class="layui-btn" >打印</button>