The article is reproduced from: http://www.jq22.com/jquery-info347
Plugin description: A jQuery plugin jqprint that prints the page by clicking the page button.
2017-2-17 update (modify the invalid address of jquery-migrate-1.0.0.js, the official migration assistance plugin provided by jQuery)
Please note! Many friends encountered Cannot read property 'opera' of undefined error problem is juqery version compatibility problem
Solution: Add the migration assistant plugin jquery-migrate-1.0.0.js to solve the version problem
1
|
|
Implementation
reference jquery and,jqprint to your page
1
2
|
<
script
language
=
"javascript"
src
=
"jquery-1.4.4.min.js"
></
script
>
<
script
language
=
"javascript"
src
=
"jquery.jqprint-0.3.js"
></
script
>
|
js
1
2
3
4
5
|
<script language=
"javascript"
>
function
a(){
$(
"#ddd"
).jqprint();
}
</script>
|
html
1
2
3
4
5
6
7
8
9
10
11
|
<
div
id
=
"ddd"
>
<
table
>
<
tr
>
<
td
>test</
td
>
<
td
>test</
td
>
<
td
>test</
td
>
<
td
>test</
td
>
<
td
>test</
td
>
</
tr
>
</
table
>
</
div
>
|
1
|
<
input
type
=
"button"
onclick
=
" a()"
value
=
"打印"
/>
|
When printing, the header and footer will be printed first, which can be realized by code or manually changing the browser's printing properties to remove the header and footer.