Step 1:
Download jquery. PrintArea. js
Js reference
Copy codeThe Code is as follows: <script language = "javascript" src = "jquery-1.7.1.min.js"> </script>
<Script type = "text/javascript" src = "jquery. PrintArea. js"> </script>
Html reference:Copy codeThe Code is as follows: <div class = "my_show">
This is displayed during printing.
</Div>
<Div class = "my_hidden">
This is hidden during printing.
</Div>
<Input type = "button" id = "print"/>
Javascript code:Copy codeThe Code is as follows: $ (document). ready (function (){
$ ("# Print"). click (function (){
$ (". My_show"). printArea ();
});
});
This plug-in also provides some configurable parameters, using $ (element). printArea (option ).
I have never used this method. If you have any questions, please leave a message.
Parameter settings:
1. mode: mode. It is triggered when the print button is clicked. The default mode is iframe. When it is set to popup, a new window page is printed.
2. popTitle: Set the title of the new window. The default value is null.
3. popClose: whether to close the window after printing is completed. The default value is false.