Jquery- Jqprint实现网页打印功能

来源:互联网 发布:网络教育网络统考 编辑:程序博客网 时间:2024/06/07 11:55
Html部分:

<div id="test">
    <style type="text/css">
    .tt tr td{
       font-size: 12px; 
    }
    </style>


    <h3 class="text-center">标题</h3>
    <table class="table table-bordered table_detail" style="margin-top: 30px;">
        <tbody class="tt">
           
        </tbody>
    </table>
</div>


按钮(自己可以添加样式:以下用的是bootsrap样式):
 

<button  type="button" class="btn btn-info btn-sm"  id='print'><i class="fa fa-print"></i>&nbsp;打印</button>


文件引入:

<import file="lib.js.jquery#jqprint" />
<script type="text/javascript">
$(document).on("click","#print",function(){  //控制按钮。
  $("#test").show();
  $("#test").jqprint();
  $("#test").hide();
});
</script>

如果要实现手动分页:在要分页的结尾处加上<div style="page-break-after:always;"></div> 
原创粉丝点击