PrintArea 插件可只列印頁面中指定區域,而不是整個視窗。適合報表、訂單、收據與證書頁面。
<script src="jquery-1.7.1.min.js"></script>
<script src="jquery.PrintArea.js"></script>
<div class="my_show">這個是列印時顯示的。</div>
<div class="my_hidden">這個是列印時隱藏的。</div>
<input type="button" id="print" />
<script>
$(document).ready(function () {
$("#print").click(function () {
$(".my_show").printArea();
});
});
</script>
使用時應確認列印樣式表已載入,並避免將互動元件放入列印區域,以免輸出結果與畫面預期不同。