Skip to content
Related Articles

Related Articles

How to print a page using jQuery ?
  • Last Updated : 15 Oct, 2020

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
My Personal Notes arrow_drop_up
Recommended Articles
Page :