Print HTML content on click using JavaScript

  • Print full screen window
  • Print Div content by id
  • Print multiple div content by id separated with comma (",") 

Print web page demo:
See the Pen Print Web Page Using JavaScript by Sartaj Husain (@sartaj-husain) on CodePen.

Print function accepts blank value or element id inside double quotes.
If blank value is passed then print method will print whole window screen else only the part or div content whose ids are provided comma (",") separated.

JavaScript Function To Print Web page

Above answer for all below questions:

  • How to print HTML content on click,
  • Print Div Content Using JavaScript,
  • Print div by id,
  • Print multiple div by id 

Hi! I am Sartaj Husain. I am a Professional Software Developer, live in Delhi. I write blogs in my free time. I love to learn and share the knowledge with others because it is no good to try to stop knowledge from going forward. So free posts and tutorials. more..

No comments