I want to print the body which only includes the selected part
on click of this method the page alignment changes
//app
<div class="header">
<ul>
<li>Home</li>
<li>Page</li>
<li>Contact</li>
</ul>
</div>
<div id="payment-receipt">
<div>
<p>Price$24.78</p>
<p>Product Status About to reach </p>
</div>
</div>
//js
printDiv() {
//Get the HTML of div
var divElements = document.getElementById('payment-receipt').innerHTML;
//Get the HTML of whole page
var oldPage = document.body.innerHTML;
//Reset the page's HTML with div's HTML only
document.body.innerHTML = "<html><head><title></title></head><body>" + divElements + "</body>";
//Print Page
window.print();
//Restore orignal HTML
document.body.innerHTML = oldPage;
}
The alignments should stay same before the click and after the click of method