I have a modal on each tenant on a table for their receipt and i only want to print the modal, but the problem is the print only works on the first tenant, and does not work on the other tenants on the table.
<script>
document.getElementById("btnPrint").onclick = function () {
printElement(document.getElementById("printThis"));
var modThis = document.querySelector("#printSection .modifyMe");
modThis.appendChild(document.createTextNode(""));
window.print();
}
function printElement(elem) {
var domClone = elem.cloneNode(true);
var $printSection = document.getElementById("printSection");
if (!$printSection) {
var $printSection = document.createElement("div");
$printSection.id = "printSection";
document.body.appendChild($printSection);
}
$printSection.innerHTML = "";
$printSection.appendChild(domClone);
}
</script>
(html)
<div id="printThis" class=" modifyMe">
<h3 class="modal-title text-center" id="myModalLabel">
(css)
@media print {
body * {
visibility:hidden;
}
#printSection, #printSection * {
visibility:visible;
}
#printSection {
position:absolute;
left:0;
top:0;
}