jQuery Print function to print div content with css

css, html, jquery, printing

Solution

You need to include the SAME stylesheet you're using in the parent page within the pop-up. You may want to make a dummy page stub/wrapper that has your stylesheet in it, then inject your HTML.

var myStyle = '<link rel="stylesheet" href="http://mysite.com/mystyle.css" />';
w.document.write(myStyle + jQuery('.table_disp').html());

Problem

I've this function for my Wordpress plugin uses jQuery that prints the content from the div with class "table_disp". How can I print the css style along with it. ``` function pop_print(){ w=window.open(null, 'Print_Page', 'scrollbars=yes'); w.document.write(jQuery('.table_disp').html()); w.document.close(); w.print(); } ``` Any idea?

Original source