JSFiddle - React, Tailwind, and code Playground

HTML

<div>
    <p>Your content here</p>
    <table  id="toPrint">
     <tr>
    <td>Neil D'zousa</td>
    <td>112233445566</td>
    </tr>
</table>
</div>
<div id="notForPrint">
    <a href="#" id="print">print</a>
</div>

JavaScript

function open() {

    if(!$('#toPrint .header').length)
    {
    var htmlTable2 = '<tr class="header">' + '<th>Name12121212</th>'
              + '<th>Phone</th>'+ '</tr>';
    var html1 = $("#toPrint").prepend(htmlTable2);
    var t=html1;
    $(t).append(htmlTable2);
    }
    window.print(); 
}
$(function() {
    $("a#print").click(open);
});