How to print a page using jQuery ?
The task is to print a page using jQuery by calling a window.print method when the user clicks on a Button. The window.print() method is sent to open the Print Dialog Box to print the current document. It does not have any parameter value.
Example::
HTML Code:
HTML
<!DOCTYPE html>
< html >
< head >
< title >
How to. print a page using jQuery.?
</ title >
</ head >
< body >
< center >
< h1 >Hello GeeksForGeeks Users</ h1 >
< h3 >
How to. print a page using jQuery.?
</ h3 >
< Button id = "sudo" onclick =
"print_current_page()" />
Print!
</ button >
</ center >
</ body >
</ html >
|
jQuery Code:
$('#sudo).click(function(){
window.print();
return false;
});
Output:
Before Clicking On Button:
After Clicking On Button:
Supported Browsers:
- Google Chrome
- Internet Explorer
- Firefox
- Opera
- Safari
Last Updated :
15 Oct, 2020
Like Article
Save Article
Share your thoughts in the comments
Please Login to comment...