Skip to content

sheik-mostafizur/print

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Print a specific content of body

How to use print functaion?

  // 1. buttonNameSelectAsCssHere
  // 2. printAreaIdNameHere

  const printBtn = document.querySelector("buttonNameAsCssHere");
  printBtn.addEventListener("click", function () {
    printArea("printAreaIdNameHere");
	window.location.reload();
  });

  function printArea(areaId) {
    var printContents = document.getElementById(areaId).innerHTML;
    var originalContents = document.body.innerHTML;
    document.body.innerHTML = printContents;
    window.print();
    document.body.innerHTML = originalContents;
  }
};

Step 1:

step_one

Step 2:

step_two

Step 3:

step_three

About

Print specific content of body using html, css, javaScript

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published