I am trying to copy a div into a new print window, which works fine but the div copied it without attachment to it.
$('#PrintNews').bind('click', function () { var printContents = new $("#divToPrint").clone(); var myWindow = window.open("", "popup", "width=1000,height=600,scrollbars=yes,resizable=yes," + "toolbar=no,directories=no,location=no,menubar=no,status=no,left=0,top=0"); var doc = myWindow.document; doc.open(); $(printContents).find("#PrintNews").remove(); doc.write($(printContents).html()); doc.document.close(); doc.focus(); doc.print(); doc.close(); }); });
How can I open this div in a new window for printing, but with all its styles, as in the original div?
source share