我正在尝试在按钮上打印特定表,单击该按钮可以正常工作,但在打印预览中未显示引导CSS
function printme(){
var divToPrint=document.getElementById('print_table');
var newWin=window.open('','Print-Window');
newWin.document.open();
newWin.document.write('<html><body onload="window.print()">'+divToPrint.innerHTML+'</body></html>');
newWin.document.close();
setTimeout(function(){newWin.close();},10);
}
<button class='btn btn-primary' onclick="printme()">Submit</button>
<table id='print_table' class='table table-bordered'>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>3</td>
</tr>
</table>