您的位置:首页 > Web前端 > JQuery

Jquery- Jqprint实现网页打印功能

2017-08-16 16:09 731 查看
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> 打印</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> 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: