window.print()
export default function printDiv({divId, title}) {
let mywindow = window.open('', 'PRINT', 'height=650,width=900,top=100,left=150');
mywindow.document.write(`<html><head><title>${title}</title>`);
mywindow.document.write('</head><body >');
mywindow.document.write(document.getElementById(divId).innerHTML);
mywindow.document.write('</body></html>');
mywindow.document.close(); // necessary for IE >= 10
mywindow.focus(); // necessary for IE >= 10*/
mywindow.print();
mywindow.close();
return true;
}
<button onclick="window.print()">print</button>
$('.print-btn').click(function(){
var printed_id = $(this).attr('data-id');
if( printed_id ){
var printed_content = $($('#' + printed_id).html());
$('body').children().css('display', 'none');
$('body').append(printed_content);
window.print();
printed_content.remove();
$('body').children().css('display', '');
}
});