innerHTML does not display the object

0

I'm using innerHTML to fill a page, its structure goes quiet, the problem is in the variables that contain objects, they are written in full instead of showing their values, I tried to add .text () in their name and resulted on a blank page, what else worked so far was the code below

$('#btnPrint').click(function() {
           var prtContent = document.getElementById("nome");
           console.log(prtContent);
           var WinPrint = window.open('', '', 'left=0,top=0,width=800,height=900,toolbar=0,scrollbars=0,status=0');
           WinPrint.document.body.innerHTML="<body onload='javascript:window.print();'><style>@font-face {font-family: Evogria;src: url('/files/Evogria.otf') format('opentype');}html{font-family: Evogria;}body{zoom: 100%;height:0;width:354px;margin-top:414px;bottom:0;margin-bottom:0;padding:0;margin-left:121px; margin-right:18px;font-weight:bold;}</style>"
           WinPrint.document.body.innerHTML+='${prtContent}';
           WinPrint.document.close();
           WinPrint.focus();
           WinPrint.print();
           document.getElementById('nome').remove()
           WinPrint.close();
        });

        }
    });

which returns an output of "[object HTMLTableCellElement]", does anyone know if the variable has stopped pulling the object, or is there something wrong with the way I'm trying to present it?     

asked by anonymous 05.07.2018 / 22:19

1 answer

2

When you give append in prtContent, use prtContent.outerHtml

WinPrint.document.body.innerHTML += prtContent.outerHTML;
    
05.07.2018 / 22:23