早睡早起,方能养生
Sleep early rise early, way to keep healthy

JQuery使用PrintArea打印预览时 没有样式

super
2023-02-13 20:20
views 1233

<div class="wrapper">
    <style type="text/css">
    	/* 样式需要写在这里 */
    </style>
	<div>
		<!-- 要打印的内容 -->
	</div>
</div>

<div class="print-btn">
    <button type="button" class="btn" onclick="preview();">打印</button>
</div>

 

<script src="https://cdn.bootcdn.net/ajax/libs/jquery/3.6.3/jquery.min.js"></script>
<script src="https://cdn.bootcdn.net/ajax/libs/PrintArea/2.4.1/jquery.PrintArea.min.js"></script>
<script>
    function preview() {
        $(".wrapper").printArea();
    }
</script>


分享
0 条讨论
top