How to Print Page Area using JavaScript

Page print in JavaScript is a simple code in JavaScript used to print the content of web pages. In this article, we will share with you a simple way to print specific div content or full-page content using JavaScript. Here we will create a JavaScript function to print div content, page area, and full web page content.
printPage() function contains some JavaScript code that helps you to implement the print feature easily on the web page. This is a very simple example, you can copy-paste, and change it according to your requirement.
JavaScript Code:
You can use this function for print a web page content:
Use printPage() function on onclick event of print button element and provide the content area div ID which you want to print.
Trigger function – HTML Code:
HTML content that you want print
Finally Complete Code: